为什么我在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:51:20  来源:igfitidea点击:

Why am I getting a deprecated warning in XCode

iphonexcodecompiler-warningsdeprecated

提问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 会显示此警告消息?

alt text http://www.angryhacker.com/toys/deprecated.jpg

替代文字 http://www.angryhacker.com/toys/deprecated.jpg

回答by Alex Reynolds

The cell.textproperty is deprecated in iPhone OS 3.0 and greater, because new table cell types allow multiple labels. Instead, use cell.textLabel.textto accomplish the same thing.

cell.text属性在 iPhone OS 3.0 及更高版本中已弃用,因为新的表格单元格类型允许使用多个标签。相反,用于cell.textLabel.text完成相同的事情。

回答by newacct

this is how properties work

这就是属性的工作方式

x = object.fieldis (by default) the same as calling x = [object field]

x = object.field(默认情况下)与调用相同 x = [object field]

and object.field = xis (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 方法