Failed to launch simulator: Operation failed with underlying error 4294956467.
Showing posts with label IBOutlet. Show all posts
Showing posts with label IBOutlet. Show all posts
Monday, April 18, 2011
Operation failed with underlying error 4294956467
Thanx Xcode, that was very informative. I'll fix it right away! Oh wait, what was that...
Thursday, November 11, 2010
How to Define UITableViewCell reuseIdentifier for loadNibNamed
When you create UITableViewCells, it's important to use reuseIdentified. This lets iOS recycle your table cells, thus improving performance and minimizing memory use. Using it is pretty simple:
Warning: you should NEVER access objects inside XIB (NIB) by magical index into array! Apple might change "something" in next Xcode release and thus break your code. You should use IBOutlets. You have been warned.
...yes, this is one of those sad "don't do as I do, but as I tell you to" cases...
static NSString *idCell = @"MyCellId";Try to reuse an already existing, but not currently used, cell created earlier with given identifier "MyCellId". If such isn't found, create a new one:
cell = (UITableViewCell *)[aTableView dequeueReusableCellWithIdentifier:idCell];
if (cell == nil)This code requires a separate stand-alone XIB, which contains nothing but your UITableViewCell. But how do you define the reuseIdenfier? That property is read-only and created when table cell is created.
{
static NSString *nibcell = @"MyCell";
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:nibCell owner:self options:nil];
cell = (UITableViewCell *)[nib objectAtIndex:0];
}
reuseIdentifierOpen your XIB in Interface Builder, select UITableViewCell object, open "Table View Cell Attributes" (press command-1) and write your hardcoded magical string "MyCellId" into "Identifier" field. Use the same string in your code as reuseIdentifier.
A string used to identify a cell that is reusable. (read-only)
@property(nonatomic, readonly, copy) NSString *reuseIdentifier
Warning: you should NEVER access objects inside XIB (NIB) by magical index into array! Apple might change "something" in next Xcode release and thus break your code. You should use IBOutlets. You have been warned.
...yes, this is one of those sad "don't do as I do, but as I tell you to" cases...
Labels:
dequeueReusableCellWithIdentifier,
IBOutlet,
interface builder,
iphone,
loadNibNamed,
mainBundle,
NSBundle,
NSString,
objectAtIndex,
reuseIdentifier,
UITableViewCell,
XIB
Subscribe to:
Posts (Atom)