OutlineView Wierdness - 'item' not being stored.
OutlineView Wierdness - 'item' not being stored.
- Subject: OutlineView Wierdness - 'item' not being stored.
- From: Pascal Harris <email@hidden>
- Date: Wed, 26 May 2010 13:12:19 +0100
I'm trying to populate an OutlineView. I've had success in the past but
now, apparently, I'm unable to do it!
Looking at this code:
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index
ofItem:(id)item
{
if (item == nil)
{
[mailListDict writeToFile:@"/test.plist" atomically:YES];
item = mailListDict;
}
if ([item isKindOfClass:[NSArray class]])
{
return [item objectAtIndex:index];
}
else if ([item isKindOfClass:[NSDictionary class]])
{
[item writeToFile:@"/test2.plist" atomically:YES];
return [item objectForKey:[[item allKeys] objectAtIndex:index]];
}
return nil;
}
- (id)outlineView:(NSOutlineView *)outlineView
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
if ([[[tableColumn headerCell] stringValue] compare:@"Key"] ==
NSOrderedSame)
{
id parentObject = [outlineView parentForItem:item] ? [outlineView
parentForItem:item] : mailListDict;
if ([parentObject isKindOfClass:[NSDictionary class]])
{
return [[parentObject allKeysForObject:item] objectAtIndex:0];
}
else if ([parentObject isKindOfClass:[NSArray class]])
{
return [NSString stringWithFormat:@"Item %d", [parentObject
indexOfObject:item]];
}
}
else
{
if ([item isKindOfClass:[NSString class]])
{
return item;
}
else if ([item isKindOfClass:[NSDictionary class]])
{
[mailListDict writeToFile:@"/test3.plist" atomically:YES];
[item writeToFile:@"/test4.plist" atomically:YES];
return [item objectAtIndex:0];
}
else if ([item isKindOfClass:[NSArray class]])
{
id parentObject = [outlineView parentForItem:item] ?
[outlineView parentForItem:item] : mailListDict;
return [[parentObject allKeysForObject:item] objectAtIndex:0];
}
}
return nil;
}
Test, Test2 and Test3 get written correctly but Test4 is empty. This is
rather frustrating - does anyone have any ideas why item seems to be empty
by the time Test4 is reached?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden