【发布时间】:2012-07-21 09:34:19
【问题描述】:
我尝试从核心数据填充我的表,但在这一行出现错误
Tips *tipy = [arr objectAtIndex:indexPath.row];
这是我的 .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;
}
app 和 arr 在 .h 文件中被声明为并在 .m 文件中合成
@property (nonatomic, retain) AppDelegate *app;
@property(nonatomic, assign) NSArray *arr;
【问题讨论】:
-
你有什么错误?你在你的文件中“#import Tips”了吗?你合成了属性吗?如果是这样,你应该写“self.arr”而不是arr
标签: iphone objective-c ios5 core-data