iphone - 什么时候用encodeWithCoder : and initWithCoder: on the iPhone?

标签 iphone objective-c cocoa-touch initwithcoder

正如我在上述主题中的问题所述,您通常需要满足哪些要求才能说“好的,我需要 encodeWithCoder:initWithCoder: 实例化这个”?通常你可以将对象状态写入 NSUserDefaults,所以我很好奇你们专家什么时候决定使用其中一个还是另一个?

最佳答案

initWithCoder: 在解压 XIB 文件时由操作系统使用;如果仔细观察,您会发现在 XIB 中创建的 View 不会调用 initWithFrame:;他们将调用 initWithCoder:

关于iphone - 什么时候用encodeWithCoder : and initWithCoder: on the iPhone?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/809588/

相关文章:

ios - 使用自动布局居中或固定到顶部

iPhone - 连接字符串和数据库文件

ios - 我想在我的 ios 项目中识别 iphone 版本

iphone - 在 iPhone 上运行 PhoneGap0.9.6 应用程序时出现异常

ios - 具有分页功能的动态表格 View

ios - 代码在 iPhone 5s+ 上运行良好,而不是以前的版本?

iPhone - 导入/导出应用程序数据?

ios - 在表格 View 中定位自定义单元格未完全显示单元格

ios - iPod Touch canOpenURL 类型为 tel ://

iphone - 哪种调整 UIImage 大小的方法更好,为什么?