I am customizing my table cells. I have this code (simplified) which is giving me an EXC_BAD_ACCESS when trying to access [indexPath row]
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"WCFPictureCell";
static NSString *CellNib = @"WCFPictureCell";
WCFPictureCell *cell = (WCFPictureCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellNib owner:self options:nil];
cell = (WCFPictureCell *)[nib objectAtIndex:0];
}
NSLog(@"iph %@", indexPath);
NSLog(@"iphrow %@", [indexPath row]);
return cell;
}
What am I doing wrong?
Thanks
The row method of NSIndexPath returns a NSInteger.
That's a primitive type, not an object.
So you can't print it using %@.
What you want is:
NSLog( @"iphrow %i", [ indexPath row ] );
You are getting a segmentation fault because %@ is used for a pointer to an object.
As you are passing an integer, NSLog will try to print an object at the memory address specified by the integer value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With