为什么我在 XCode 中收到已弃用的警告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1449868/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why am I getting a deprecated warning in XCode
提问by AngryHacker
I am getting a warning about setText method when I am not even using it. Why does XCode display this warning message?
我什至不使用 setText 方法时,都会收到有关它的警告。为什么 XCode 会显示此警告消息?
回答by Alex Reynolds
The cell.text
property is deprecated in iPhone OS 3.0 and greater, because new table cell types allow multiple labels. Instead, use cell.textLabel.text
to accomplish the same thing.
该cell.text
属性在 iPhone OS 3.0 及更高版本中已弃用,因为新的表格单元格类型允许使用多个标签。相反,用于cell.textLabel.text
完成相同的事情。
回答by newacct
this is how properties work
这就是属性的工作方式
x = object.field
is (by default) the same as calling x = [object field]
x = object.field
(默认情况下)与调用相同 x = [object field]
and object.field = x
is (by default) the same as calling [object setField:x]
并且object.field = x
(默认情况下)与调用相同[object setField:x]
回答by Allen Lin
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"
以上两个答案都非常正确。只是添加一些来自 Apple 开发人员的参考。相信这会解决你所有的问题。请看一看“对象消息传递”的会话
回答by Dan McClain
By setting a class's field the way you are, you are actually calling the setText method
通过按照您的方式设置类的字段,您实际上是在调用 setText 方法