让应用支持 iCloud 及多线程编程入门
一、完善文档应用
在处理颜色选择相关内容时,需要完成 chooseColor: 方法的实现:
- (IBAction)chooseColor:(id)sender {
NSInteger selectedColorIndex = [(UISegmentedControl *)sender
selectedSegmentIndex];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setInteger:selectedColorIndex forKey:@"selectedColorIndex"];
}
为了避免用户返回主列表时文档未保存,需要在 viewWillDisappear: 方法中添加代码来关闭文档:
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
UIDocument *doc = self.detailItem;
[doc closeWithCompletionHandler:nil];
}
完成这些修改后,这个基于文档的应用就可以正常使用了。可以创建、编辑
超级会员免费看
订阅专栏 解锁全文
50

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



