• 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: Loading saved file into NSArrayController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading saved file into NSArrayController


  • Subject: Re: Loading saved file into NSArrayController
  • From: Hans van der Meer <email@hidden>
  • Date: Mon, 18 Feb 2008 21:18:01 +0100


On 18 feb 2008, at 11:35, Mike Abdullah wrote:

There is nothing technically wrong with doing this, but if you do so every time the array is modified, your code will get rather messy and quickly. Instead, just implement the standard array accessor methods in your model:

-insertObject:in<Key>AtIndex: and -removeObjectFrom<Key>AtIndex:

As a result KVO notifications will be sent automatically, the notifications will be better tuned to the actual changes, and you'll end up with less code.

I did so but somehow implementing these this does NOT work for me!
Here is my code: -insertObject:in<Key>AtIndex: is in my class and is called inside a loop where successive solution objects are inserted in the solutions array. Is there something else I am missing?


- (void) insertObject:(id)anObject inSolutionsAtIndex: (NSUInteger)anIndex; {
[solutions addObject:anObject];
}


... <loop inserts solution objects>
	[self insertObject:solution inSolutionsAtIndex:0];
// the tableview does not update.

Besides, iff it worked there would be a kvo notification with every inserts, whereas I understand that bracketing will result in one notification only; please correct me if I am wrong here.

On 18 Feb 2008, at 09:26, Hans van der Meer wrote
On 17 feb 2008, at 03:25, mmalc crawford wrote:

On Feb 16, 2008, at 9:34 AM, Hans van der Meer wrote:

It might be of use to remember that changes within an NSMutableArray (addObject, remove...) do not by themselves lead tot calling the class's observers. I found it useful to bracket the changes in this manner:
[self willChangeValueForKey:@"theArray"];
// changes to the contents of the array
[self didChangeValueForKey:@"theArray"];


Don't do this.
RTFineM.

Please forgive me my ignorance. But I do not understand why the change bracketing should not be done. I have struggled a lot with updating a NSMutableArray bound in IB to an NSArrayController. It was (at least for me) impossible to get changes like addObject to be reflected in the coupled tableview UNLESS I bracketed the changes in the manner indicated above.


I would gladly learn where I am erring. So please could you elaborate on this statement and indicate how then the coupling array-IBbinding-tableview can be effected.

Hans van der Meer




_______________________________________________

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: 
 >Loading saved file into NSArrayController (From: Davide Scheriani <email@hidden>)
 >Re: Loading saved file into NSArrayController (From: Mike Abdullah <email@hidden>)
 >Re: Loading saved file into NSArrayController (From: Davide Scheriani <email@hidden>)
 >Re: Loading saved file into NSArrayController (From: Mike Abdullah <email@hidden>)
 >Re: Loading saved file into NSArrayController (From: Hans van der Meer <email@hidden>)
 >Re: Loading saved file into NSArrayController (From: mmalc crawford <email@hidden>)
 >Re: Loading saved file into NSArrayController (From: Hans van der Meer <email@hidden>)
 >Re: Loading saved file into NSArrayController (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Height and location of text within a line in NSLayoutManager ignoring spacing?
  • Next by Date: Re: Loading saved file into NSArrayController
  • Previous by thread: Re: Loading saved file into NSArrayController
  • Next by thread: Re: Loading saved file into NSArrayController
  • Index(es):
    • Date
    • Thread