• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Collecting my wits...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Collecting my wits...


  • Subject: Collecting my wits...
  • From: David Wood <email@hidden>
  • Date: Tue, 28 May 2002 10:20:49 -0400

The following code works, and works well in this intermediate stage. The problem is, it could work *better*:

- (void)tableView:(NSTableView *)tableView
setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn
row:(int)row
{
Subplot *subpChange = [subplotKeys objectAtIndex:row];
NSString *subpCol = [tableColumn identifier];

if ([subpCol isEqual:@"name"]) {
// We need to change the lookup name in characterDict
[subplotDict removeObjectForKey:[subpChange name]];
[subpChange takeValue:object forKey:subpCol];
[subplotDict setObject:subpChange forKey:[subpChange name]];
} else {
[subpChange takeValue:object forKey:subpCol];
}

[subplotKeys sortUsingSelector:@selector(compare:)];
[listSubps reloadData];
}

Here's the class arrangement so far:

SSDocument (SS, by the way, stands for 'Subplot Switchboard')
SubplotCollection (controls Subplot NSTableView and acts as collection of Subplots)
Subplot
CharacterCollection (controls Character NSTableView and acts as collection of Characters)
Character

Also, the collection classes use both an NSMutableDictionary and NSMutableArray to track the list of subplots -- one by name, and one by linear order (alphabetized by name).

I was having trouble with the program because previously, I used only the:
[subpChange takeValue:object forKey:subpCol];
command, and the name on the object would be changed, but it would still be in the dictionary under the old name.

As the program grows, the names of the Character and Subplot objects may change in different ways, and I need to figure out how to handle those in a consistent way. Notifications come to mind (a [Character|Subplot]NameDidChange message from the character or subplot item to its respective collection?), but then how do I handle the name change in the code above, which already works, and changes the object name in a nonstandard way (i.e. not using the setName method)?

Again, please pardon me if the answer to this question appears in a book somewhere, but I'm still going through those and developing this program parallel to them.

And in reference to a previous question and answer session, I've settled for my original paradigm: a window with a list of characters and a list of subplots. Particulars about the objects in each list will be handled by info windows.


--David http://skipjack.bluecrab.org/~dwood

"Hope is the thing which fetters..."
--What Emily Dickinson SHOULD have said.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: "Pressed" toolbar Items
  • Next by Date: Shearing with NSAffineTransform
  • Previous by thread: Re: "Pressed" toolbar Items
  • Next by thread: Shearing with NSAffineTransform
  • Index(es):
    • Date
    • Thread