It looks like you're new here. If you want to get involved, click one of these buttons!
KingofChaos
Posts: 25Registered Users
#import \"ViewController.h\"
@interface ViewController ()
@end
@implementation ViewController
@synthesize tableView1;
@synthesize array;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
grommetext1.keyboardType = UIKeyboardTypeNumberPad;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
#pragma mark
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [self.array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *uniqueIdentifier = @\"customerCell\";
CustomerCell *cell = nil;
cell = (CustomerCell *) [self.tableView1 dequeueReusableCellWithIdentifier:uniqueIdentifier];
CustomerCell *array = [self.array objectAtIndex:[indexPath row]];
if(!cell)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@\"CustomerCell\" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[CustomerCell class]])
{
cell = (CustomerCell *)currentObject;
break;
}
}
}
cell.label1.text = cell.name;
return cell;
}
@end
Replies
New app - See screenshots and details at www.globaclock.com.
If you want to
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomePost the header for your custom cell type CustomerCell.
Also post the code that is throwing the error. I did not see any reference to "name" in the code you posted.
You might need to cast a generic cell to a CustomerCell before you can reference a property from your custom cell.
Part of the code you posted does not make sense to me. First you try to dequeue a reusable cell, which is fine. Then you try to extract another CustomerCell object that you call "array". If it's a custom table view cell, why do you call it array? And why are you storing table view cells to an array? The name "array" is a very confusing name for a table view cell. And, you should not be saving your table view cells into an array. That will prevent the system from deallocating them when it is done with them.
This is the code I am talking about.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAnd I just followed a tutorial and did what they told me to do, Im still a beginner, and am trying to learn how a tableview works with custom cells.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomePost the whole method that contains that line and put that line in bold.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeNow I'm using this code:
- (CustomerCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CustomerCell *cell = [tableView dequeueReusableCellWithIdentifier:@\"customerCell\"];
if (cell == nil) {
// Load the top-level objects from the custom cell XIB.
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@\"CustomerCell\" owner:self options:nil];
// Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
cell = [topLevelObjects objectAtIndex:0];
}
return cell;
}
And I get this error in the output:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome