i actually dont see my error:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; FriendTableViewCell *cell = (FriendTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[FriendTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; [[NSBundle mainBundle] loadNibNamed:@"FriendTableViewCell" owner:self options:nil]; cell = friendCell; } cell.lblNickname.text = @"Tester"; return cell; }
What am i doing wrong? I checked all twice.. but dont see the error.
Thanks for your help!
You're returning friendCell, and it's very likely nil.
Your code looks fine, so make sure you have your Interface Builder file set up right. In FriendTableViewCell.xib, be sure the File's Owner is your table view controller and that you correctly set the cell to be an outlet to friendCell (which I assume is a UITableViewCell).
For me, it worked doing this:
if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; }
UPDATE
Place the above code in the following method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Just put it BEFORE editing the tableViewCell
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