Синтаксис Цель-C Вопрос для начинающих - PullRequest
1 голос
/ 23 декабря 2009

я хочу использовать appRecord.myName в viewDidLoad,
когда я помещаю это там, это ошибка, что appRecord необъявлен, как объявить это?

- (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;
}

Ответы [ 2 ]

1 голос
/ 23 декабря 2009

У вас есть #import "AppRecord.h" вверху этого файла?

0 голосов
/ 23 декабря 2009

Похоже, что appRecord объявлено (= делает это). Возможно, вам нужно разыграть его, хотя: (AppRecord *)[self.entries objectAtIndex:indexPath.row]. Что бы вы ни делали, чтобы проверить, существует ли appRecord, попробуйте следующее и запустите:

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

Вы должны получить описание объекта appRecord с адресом памяти, если он существует. Дайте мне знать, если это поможет, или вам нужны дальнейшие объяснения.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...