On Mar 7, 2009, at 11:05 PM, Luke Evans wrote:

Well, what actually happens is that -selectedObjects almost always returns an empty array. Sending -setContent: does not appear to result in this content being available as the selectedObject in the way described (or there's other magic to get this to happen?).
<snip>
- (void)awakeFromNib {
        [objController setContent:@"This is a nice string"];
        NSArray *selectedObjects = [objController selectedObjects];
id selectedObject = (selectedObjects && [selectedObjects count])? [selectedObjects objectAtIndex:0] : nil; NSLog(@"The selectedObjects were: %@,\n the selectedObject was: %@", selectedObjects, selectedObject);
        
        [objController setContent:@"Another string"];
        selectedObjects = [objController selectedObjects];
selectedObject = (selectedObjects && [selectedObjects count])? [selectedObjects objectAtIndex:0] : nil; NSLog(@"The selectedObjects were: %@,\n the selectedObject was: %@", selectedObjects, selectedObject);
}


What happens when this is run is that the first time -setContent: is used, the -selectedObjects method returns the object (the string).

The second time however, has -selectedObjects return NO object (i.e. the empty array).

IIRC, NSObjectController, as a super class has some behavior that doesn't make sense to an NSObjectControlelr proper. Because of this it is possible that the selection change has been deferred to the run loop. You can manually run the run loop to see if this is the case.

It seems to me that there is no need for you to use -selectedObjects when there will always be a 1:1 relationship between the controller content and the selected object.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to