• 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: NSArraycontroller, Bindings nad NSTableview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArraycontroller, Bindings nad NSTableview


  • Subject: Re: NSArraycontroller, Bindings nad NSTableview
  • From: Louis Demers <email@hidden>
  • Date: Fri, 18 Jul 2008 00:20:46 -0400

Well, as a reply to my own message . I seem to have gotten it to work very nicely !

I recreated a fresh project and let my NSArrayController instance create and manage the storage for me. In addition to possible misconfiguration, It seems I was caught by the fact that NSArrayController does not add the object immediately upon creation, since I was checking the count immediately after sending the "add" message. From the doc

-------------
add: Creates and adds a new object to the receiver’s content and arranged objects.
...
Special Considerations
Beginning with Mac OS X v10.4 the result of this method is deferred until the next iteration of the runloop so that the error presentation mechanism can provide feedback as a sheet.


-------------



Cheers.


On 17-Jul-08, at 11:52 , Louis Demers wrote:

Hi,
I've programmed for a while in Cocoa, with bindings... But for the first time I need a NSTableView and I would like to use NSArrayController with bindings to do as much work as possible and with the minimum amount of code. But I've had nothing but failure, even after inspecting many examples and tutorials on google.


Initially I believed that NSArrayController would store the array itself but I now resorted to having my own NSMutableArray (with getter and setters) in my model.

A button bound to the "add" or the "insert" method of the NSArrayController just does nothing. To debug things, I created a subclass of NSArrayController to intercept the "add" method and confirm that it does get called but it does not create and insert any object. The NSControllerArray instance is configured to generate object of class toto (with editable chedked and preapres content uncheked).

and it's binding is pointing to where my NSMutableArray is located

Controller Content
	bind to myController instance
	controller Key is empty
	Model Key Path is set to the accessor of my array

In my subclass of the NSArrayController array, if I create a toto object and use addObject, it works ! Even the NSTableView gets updated !

-	(void)add:(id)sender;
{
	[super add:sender];		// Does not work
	NSLog(@"count %d" , [[super content] count]);

	[super addObject:[[toto alloc] init]]; 	// Works
	NSLog(@"count %d" , [[super content] count]);
}


Any clues why the "add" method does not work ?

If anybody as such a trivial sample/tutorial, I'd be very grateful, (after a third nights of banging my head against this problem)


Thanks.


PS: Xcode 3.1 Component versions Xcode IDE: 1099.0 Xcode Core: 1100.0 ToolSupport: 1086.0 IB Version 3.1 (670)


Louis Demers eng. www.obzerv.com


_______________________________________________

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

Louis Demers eng. www.obzerv.com


_______________________________________________

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


References: 
 >NSArraycontroller, Bindings nad NSTableview (From: Louis Demers <email@hidden>)

  • Prev by Date: Re: Toolbar code in separate Controller?
  • Next by Date: Re: IBOutlet to same control in different nibs
  • Previous by thread: Re: NSArraycontroller, Bindings nad NSTableview
  • Next by thread: NSViewController Binding Problem continued
  • Index(es):
    • Date
    • Thread