为什么我在 XCode 中收到已弃用的警告
当我什至没有使用 setText 方法时,我收到了有关它的警告。为什么 XCode 会显示此警告消息?
I am getting a warning about setText method when I am not even using it. Why does XCode display this warning message?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
cell.text
属性在 iPhone OS 3.0 及更高版本中已弃用,因为新的表格单元格类型允许多个标签。相反,使用 cell.textLabel.text 来完成同样的事情。The
cell.text
property is deprecated in iPhone OS 3.0 and greater, because new table cell types allow multiple labels. Instead, usecell.textLabel.text
to accomplish the same thing.这就是属性的工作原理
相同
x = object.field
(默认情况下)与调用x = [object field]
和object.field = x
code> (默认情况下)与调用[object setField:x]
相同this is how properties work
x = object.field
is (by default) the same as callingx = [object field]
and
object.field = x
is (by default) the same as calling[object setField:x]
上面两个答案非常正确。只是添加一些来自苹果开发人员的参考。相信能解决你所有的疑问。请查看“对象的会话消息传递”
The up two answers are more than correct. Just to add some references from Apple's Dev. Believe that will solve all of your questions. Please take a look at the session for "Object Messaging"
通过按照您的方式设置类的字段,您实际上是在调用 setText 方法
By setting a class's field the way you are, you are actually calling the setText method