打造 MyStuff 应用:从表格展示到细节编辑的全流程指南
1. 引入 MyWhatsit 对象
在 MSMasterViewController.m 文件中,我们需要让其知晓 MyWhatsit 对象。在文件顶部,其他 #import 语句下方添加如下代码:
#import "MyWhatsit.h"
接着,回到 -tableView:cellForRowAtIndexPath: 方法,将该方法的最后三条语句替换为:
MyWhatsit *thing = things[indexPath.row];
cell.textLabel.text = thing.name;
cell.detailTextLabel.text = thing.location;
return cell;
这里,我们从 indexPath 对象获取要绘制行的 MyWhatsit 对象,并将其存储在 thing 变量中。然后,使用 name 和 location 属性设置单元格的 textLabel (标题)和 detailTextLabel (副标题)。
需要注意的是,表
超级会员免费看
订阅专栏 解锁全文
1

被折叠的 条评论
为什么被折叠?



