• 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
NSObjectController's removeObject just a stub?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSObjectController's removeObject just a stub?


  • Subject: NSObjectController's removeObject just a stub?
  • From: Richard Wolf <email@hidden>
  • Date: Sun, 1 Jan 2006 16:38:21 -0600

Hi guys, I am kind of curious about something ...

Does NSObjectController's removeObject actually work? NSArrayController's removeObject absolutely works ... but I suspect that NSObjectController's is just a stub. If so, I will certainly report that as a bug to Apple (either to be fixed or fixed in the documentation) ... but I want to make sure my understanding is correct before I do. My bet is that I'm wrong and not Apple. :)

Basically, I created a simple Cocoa application and did not add any extra code to it ... just messed with its MainMenu.nib. In the nib, I instantiated a NSObjectController object and left "Automatically Creates Content" unchecked. Nextly, I created two buttons and set the controller as their targets; I set the first button's action to "add" in the controller, the other to "remove." My understanding is that these actions invoke the "addObject" and "removeObject" methods within the controller. I then created a controller key -- "value" -- keeping the controller's object class name set to NSMutableDictionary. Finally, I bound a couple of user interface widgets (a slider and text field) to "value" just for testing.

So I ran the app and it started out by behaving exactly as I expected. With no selection object, the slider and text field were inactive. I clicked on my "Add" button and immediately the widgets came alive, working as normal. However, when I clicked on my "Remove" button, nothing happened. It's my understanding that my controller should have gone back to having no selection object and that should have disabled my slider and text field. To test my understanding, I bound two text fields to the controller's "canAdd" and "canRemove" keys and re-ran the app. Here are the results:

App starts:
   Selection object:  None
   Can add?           Yes
   Can remove?        No

After click on Add button:
   Selection object:  Available
   Can add?           No
   Can remove?        Yes

After click on Remove button:
   Selection object:  (Still) Available
   Can add?           No
   Can remove?        Yes

I setup another simple application, this time using a table and an NSArrayController and addObject and removeObject worked exactly as advertised. canAdd and canRemove also reported exactly what I expected. Now according to the documentation:

http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaBindings/Concepts/CntrlContent.html#//apple_ref/doc/uid/ TP40002147-183285-BBCDFJHD

addObject and removeObject are synonymous with setContent ... with removeObject passing nil as an argument. But I am not sure that it really is passing nil.

Am I missing something?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSObjectController's removeObject just a stub?
      • From: Richard Wolf <email@hidden>
  • Prev by Date: Trying to draw numbers into a dock icon badge
  • Next by Date: Pointer to id
  • Previous by thread: Re: Trying to draw numbers into a dock icon badge
  • Next by thread: Re: NSObjectController's removeObject just a stub?
  • Index(es):
    • Date
    • Thread