• 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
Re: NSObjectController selection - now you see it, now you don't
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSObjectController selection - now you see it, now you don't


  • Subject: Re: NSObjectController selection - now you see it, now you don't
  • From: Keary Suska <email@hidden>
  • Date: Sun, 8 Mar 2009 09:38:20 -0600


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 (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


  • Follow-Ups:
    • Re: NSObjectController selection - now you see it, now you don't
      • From: Luke Evans <email@hidden>
References: 
 >NSObjectController selection - now you see it, now you don't (From: Luke Evans <email@hidden>)

  • Prev by Date: Re: NSDrawNinePartImage draws slowly in CALayer
  • Next by Date: Making a border-less window is not working
  • Previous by thread: NSObjectController selection - now you see it, now you don't
  • Next by thread: Re: NSObjectController selection - now you see it, now you don't
  • Index(es):
    • Date
    • Thread