views:

182

answers:

2

Hello, i want to use the appRecord.myName in the viewDidLoad,
when i put it there it error up that appRecord is undeclared, how to declare it?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *CellIdentifier = @"pilotWay";
    static NSString *PlaceholderCellIdentifier = @"PlaceholderCell";

    int nodeCount = [self.entries count];

    if (nodeCount == 0 && indexPath.row == 0)
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];
        if (cell == nil)
     {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                reuseIdentifier:PlaceholderCellIdentifier] autorelease];   
            cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
      cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }

     cell.detailTextLabel.text = @"load";

     return cell;
    }

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
               reuseIdentifier:CellIdentifier] autorelease];
     cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    if (nodeCount > 0)
    {
        AppRecord *appRecord = [self.entries objectAtIndex:indexPath.row];


     cell.textLabel.text = appRecord.myName;          
     cell.textLabel.text = appRecord.appName;
    }

    return cell;
}
A: 

It appears that appRecord is declared (= does that). Perhaps you need to cast it, though: (AppRecord *)[self.entries objectAtIndex:indexPath.row]. Whatever you do, to check whether appRecord exists, try the following and run:

NSLog(@"appRecord: %@", appRecord);

You should get a description of the object appRecord with a memory address if it exists. Let me know if any of this helps, or if you need further explanation.

Jonathan Sterling
The class isn't declared anywhere, which I imagine is what his problem is.
Azeem.Butt
thanks for the respond! appRecord declared in a method that doesn't get called from the viewDidLoad so appRecord is still undefined.
dani_au
the class is declared, everything works fine in the class, but if i want to use the appRecord.myName in the viewDidLoad for another purpose the appRecord is yet been define, how to define it?
dani_au
+1  A: 

Do you have #import "AppRecord.h" at the top of that file?

dreamlax
yes, everything works fine in the class, but if i want to use the appRecord.myName in the viewDidLoad for another purpose the appRecord is yet been define, how to define it?
dani_au