• 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: NSTableView doesn't show data until I click on a header
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView doesn't show data until I click on a header


  • Subject: Re: NSTableView doesn't show data until I click on a header
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 03 May 2012 09:26:05 -0700

On May 3, 2012, at 03:52 , Koen van der Drift wrote:

> Thanks! I was indeed using remove<key>AtIndexes: , but set<Key> seems a bit easier to do.

The setter is not quite so easy at it seems. You should declare the property with the 'copy' option, so that the parameter is copied by any @synthesized setter. If you write your own setter, then you need to make sure you make the copy yourself. Otherwise, the caller can (in effect) change your array ivar at will (by passing a NSMutableArray object to the setter, and mutating it later).

Also, at the moment you make the copy, there are *three* arrays in existence: your current ivar value, the copy (your new ivar value), and the parameter to the setter. If the arrays are large or otherwise expensive to create, then the copying and memory consumption of the extra copies might be uncomfortably unperformant.

In fact, depending on the expected sizes of the arrays involved, the "best" implementation of the setter might actually be one that avoids making the copy:

	- (void) setMyArray: (NSArray*) myArray {
		[myArrayIvar removeObjectsAtIndexes: … index set of all elements …];
		[myArrayIvar addObjectsFromArray: myArray];
	}

IOW, it would use the wordier code technique that you started out to avoid. :)


_______________________________________________

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: 
 >Re: NSTableView doesn't show data until I click on a header (From: Koen van der Drift <email@hidden>)
 >Re: NSTableView doesn't show data until I click on a header (From: Koen van der Drift <email@hidden>)
 >Re: NSTableView doesn't show data until I click on a header (From: Roland King <email@hidden>)
 >Re: NSTableView doesn't show data until I click on a header (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: Drawing unicode glpyhs
  • Next by Date: Re: How can I prevent UITableViewRowAnimationAutomatic to slide down my UISearchBar?
  • Previous by thread: Re: NSTableView doesn't show data until I click on a header
  • Next by thread: Window "snapping" to main screen
  • Index(es):
    • Date
    • Thread