Ios 将NSString添加到特定UITableViewCells

Ios 将NSString添加到特定UITableViewCells,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我已经创建了一个coreData应用程序,我正在保存我的NSString,并使用 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]

我已经创建了一个coreData应用程序,我正在保存我的NSString,并使用

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    Person *person = [self.fetchedResultsController objectAtIndexPath:indexPath];
    cell.textLabel.text = [NSString stringWithFormat:@"%@",person.personType];

    return cell;
}
我想让这些结果在10个UITableView单元格之后开始显示,在前10个单元格中,我只需添加一个预设的NSString,它将始终保持不变?任何帮助都很好

使用if语句并检查indexPath.row


您的numberOfRowsInSection方法还需要返回10行。

In Person*Person=[self.fetchedResultsController对象索引路径:indexPath-10];-10似乎不起作用?为什么不起作用?请详细说明。它表示“int类型的不兼容整数到指针转换发送到nsindepath”。这可能是因为第节中的数字增加了10吗?这是我在numberOfRowsInSection id secInfo=[[self.fetchedResultsController sections]objectAtIndex:section]中的内容;返回[secInfo numberOfObjects]+10;我试过了,但运气不好。我没看清楚。查看我的最新更新。您需要使用新行创建一个全新的索引路径变量,并将其传递给获取的结果。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    if (indexPath.row < 10) {
        cell.textLabel.text = ... // some hardcoded value for the first 10 rows
    } else {
        NSIndexPath *newPath = [NSIndexPath indexPathForRow:indexPath.row - 10 inSection:indexPath.section];
        Person *person = [self.fetchedResultsController objectAtIndexPath:newPath];
        cell.textLabel.text = person.personType;
    }

    return cell;
}