• 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: nonatomic vs atomic assign/retain
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nonatomic vs atomic assign/retain


  • Subject: Re: nonatomic vs atomic assign/retain
  • From: Matt Neuburg <email@hidden>
  • Date: Fri, 09 Sep 2011 13:35:08 -0700

On Wed, 07 Sep 2011 13:06:28 -0500, glenn andreas <email@hidden> said:
>
>> Anyway. But I am curious - can you provide an example where you
>> modified an outlet?
>
>On iOS, a common technique to make complex table view cells is to put them in their own nib files, have a table view controller have:
>
>@property (nonatomic, retain) IBOutlet UITableViewCell *loadedCell;
>
>and then:
>
> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
>{
>	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: self.identifier];
>	if (!cell) {
>		[[NSBundle mainBundle] loadNibNamed:@"ComplexTableViewCell" owner:self options:nil];
>		cell = [[self.loadedCell retain] autorelease];
>		self.loadedCell = nil;
>	}
>	// configure and return cell...
>}
>

(1) I don't think that's an example of modifying an *outlet*, though. What you did was to modify the value of an ivar. The outlet is the name "loadedCell" embedded in the nib; you didn't do anything about that (i.e. you didn't magically change the *name*). You just *used* the outlet, in a perfectly normal way: you loaded the nib with self as the owner and KVC was used to cause a certain newly created instance (the cell) to be passed to setLoadedCell:.

(2) On iOS 4 it's better in this repeated loading situation to use UINib instead of NSBundle to load the nib:

  UINib* theCellNib = [UINib nibWithNibName:@"ComplexTableViewCell" bundle:nil];
  [theCellNib instantiateWithOwner:self options:nil];

m.

--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________

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

  • Prev by Date: Re: NSBrowser column titles disappear when scrolled [SOLVED]
  • Next by Date: Re: Set a view's delegate using IB
  • Previous by thread: Re: nonatomic vs atomic assign/retain
  • Next by thread: using AppKit additions in background threads
  • Index(es):
    • Date
    • Thread