On Wed, 07 Sep 2011 13:06:28 -0500, glenn andreas <gandr...@mac.com> 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 = m...@tidbits.com, <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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com