Reputation: 767
I have an UIViewController with an UITableView inside him, I draw the items inside my Table using the Interface (Drag and drop Labels, and UITextViews) my table have 25 rows.
Now it's time to link my labels with IBOutlets for this I create a Subclass of TableViewCell Like this:
TableViewCell.h
@property (nonatomic, retain) IBOutlet UILabel *label1;
TableViewCell.m
@synthesize label1 = _label1;
And I use this code for change my first label:
- (UITableViewCell *)tableView:(UITableView *)tableView2 cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [menuItems objectAtIndex:indexPath.row];
HobbiesTableViewCell *cell = [tableView2 dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[HobbiesTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.label1.text = @"GG";
return cell;
}
But I saw a little problem, When I open my View (in simulator) is too slow to open (I think my table is loading), for try to solve this problem I delete the nonatomic
of my property and my View open faster.
But I have one question, When I create Properties I always put the command nonatomic
, and in this project I had to take it off because the slowness, have a problem to take off the nonatomic
in this property?(Since the labels will never be changed!)
Upvotes: 0
Views: 1028
Reputation: 2107
From what you have listed, I would rather blame not the table view, but the way you fill .menuItems
. Does its contents come from the internet or a file? If yes, I guess the problem is that you perform access to a remote data source on the main thread
UPD: After a short talk with the PO it became clear the the issue was because of having 25 cells with different Reuse ID's.
Upvotes: 1
Reputation: 3767
You should make label1
weak, as it is is in Storyboard. You also don't need to @synthesize
anymore.
Also, if you are dequeuing with different identifiers, you are really not dequeueing. Prototype cells should have one identifier in storyboard.
NSString *CellIdentifier = @"MyCellID"
HobbiesTableViewCell *cell = [tableView2 dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Nonatomic should increase performance, and is not causing your problem.
Upvotes: 1