• 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: Some crash.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some crash.


  • Subject: Re: Some crash.
  • From: Chris Hanson <email@hidden>
  • Date: Sat, 02 Aug 2008 17:08:37 -0700

On Aug 2, 2008, at 2:07 PM, Sandro Noel wrote:

when the Array is filled on application init, the data displays fine, but if I add to the array "programatically"
the new data is not displayed, i've tried:
[self didChangeValueForKey:@"transactions"];
and [transactionTableView reloadData];


If you're using bindings, you can't just manipulate an NSMutableArray instance variable directly and expect it to post KVO notifications. And don't try to "cheat" and put KVO notifications around all of the various manipulation of your mutable array, either; you'll clutter your code and wind up with subtle bugs if you forget one or use the wrong one in the wrong case.

Instead, just use -mutableArrayValueForKey: to get a proxy to the property and manipulate that. It will post KVO notifications and also manipulate the instance variable that you have backing the property. If you need to intercept the modifications to your property, you can override the mutable-array KVC methods described in <Foundation/ NSKeyValueCoding.h> or in the Key-Value Coding Guide.

 -- Chris

_______________________________________________

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: Some crash.
      • From: Sandro Noel <email@hidden>
References: 
 >Some crash. (From: Sandro Noel <email@hidden>)
 >Re: Some crash. (From: "Adam R. Maxwell" <email@hidden>)
 >Re: Some crash. (From: Sandro Noel <email@hidden>)

  • Prev by Date: Re: Coding around a known bug
  • Next by Date: Re: Faster alternative to NSImage draw/composite?
  • Previous by thread: Re: Some crash.
  • Next by thread: Re: Some crash.
  • Index(es):
    • Date
    • Thread