我有一NSObject堂课叫Post. Apost有财产URL。当我的应用程序启动时,会使用 URL 创建新帖子并添加到名为 _objects 的数组中。选择表格单元格时,我想将某些内容设置为post.urlin _objects[indexPath.row]。
添加到表中:
NSMutableArray *newPosts = [[NSMutableArray alloc] initWithCapacity:0];
for (SomeElement *element in postNodes) {
Post *post = [[Post alloc] init];
[newPosts addObject:post];
post.title = [[element firstChild] content];
post.url = [element objectForKey:@"href"];
}
_objects = newPosts;
如果我_objects[indexPath.row]在选择一个单元格时调用它,它会返回或类似的东西。