小编Jay*_*nyi的帖子

使用核心数据中的数组填充表视图

我尝试从核心数据填充我的表,并在此行给出错误

Tips *tipy = [arr objectAtIndex:indexPath.row];
Run Code Online (Sandbox Code Playgroud)

这是我的.m文件

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return [arr count];
}

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

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[ UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
    Tips *tipy = [arr objectAtIndex:indexPath.row]; 
    cell.textLabel.text = [tipy tipdescription];
    cell.detailTextLabel.text = [tipy.tipnumber stringValue];

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

app和arr在.h文件中声明,并在.m文件中合成

@property (nonatomic, retain) AppDelegate *app;
@property(nonatomic, assign) NSArray *arr;
Run Code Online (Sandbox Code Playgroud)

iphone core-data objective-c ios5

0
推荐指数
1
解决办法
172
查看次数

标签 统计

core-data ×1

ios5 ×1

iphone ×1

objective-c ×1