• 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: Confused about bindings and NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Confused about bindings and NSTableView


  • Subject: Re: Confused about bindings and NSTableView
  • From: Frédéric Testuz <email@hidden>
  • Date: Wed, 8 Dec 2004 18:54:39 +0100

Le 8 déc. 04, à 17:30, Juan Pablo Pertierra a écrit :

So, i have a table view which is bound to an NSMutableArray. I have followed the same bindings used in:

http://developer.apple.com/samplecode/Fiendishthngs/Fiendishthngs.html

However in this example they access the array directly, and they seem to add objects to the table with [array addObject:object], which works when the application is compiled. When i attempted this, the table wouldn't refresh correctly and i had to implement insertObject: at<key>AtIndex and removeObjectFrom<Key>AtIndex methods.

I think it's normal that addObject: don't notify for the modification. Otherwise there would be no method to modify a mutable array without notification. There would be a recursiv problem.


To add an object and the observer to be notify access your mutable array with the set/get method you define or through the result of mutableArrayValueForKey:

exemple : if you have a NSDocument sublaclass MyDocument with an ivar myMutableArray, inside one of the MyDocument method :

theArray=[self mutableArrayValueForKey:@"myMutableArray"];
[theArray addObject:anObject];

The document said that mutableArrayValueForKey: return an NSMutableArray, but IIRC it's a proxy to the array.

Now my table will refresh and items are added, but I get an error:

*** Illegal NSTableView data source (<MyController: 0x3391a0>). Must implement numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:

I don't get it. I can't figure out why in the Apple sample listed above they can just access the array directly, while my table won't refresh if I do it. I used bindings in the same way. And if I have to implement numberOfRows... and objectValyeForTable... methods, why use bindings anyway??? I thought bindings were supposed to take care of all this code. Do I really need the insertObject: and removeObject.. methods if i'm using bindings? And if so why aren't these methods implemented in the Apple sample?

Thanks for your time, this list is invaluable.
Juan <confused look>

-- Frédéric Testuz <mailto:email@hidden>

_______________________________________________
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: Confused about bindings and NSTableView
      • From: Kevin Callahan <email@hidden>
References: 
 >Confused about bindings and NSTableView (From: Juan Pablo Pertierra <email@hidden>)

  • Prev by Date: Re: [OT] Document Icon Templates
  • Next by Date: Re: Confused about bindings and NSTableView
  • Previous by thread: Re: Confused about bindings and NSTableView
  • Next by thread: Re: Confused about bindings and NSTableView
  • Index(es):
    • Date
    • Thread