SetText is Deprecated

℡╲_俬逩灬. 提交于 2020-01-05 08:09:20

问题


Hi I am working out Xcode and Obj-C and I am getting this warning:

Deprecations: 'setText:' is deprecated

I am wondering what the new method is

This is my code:

[cell setText:[NSString stringWithFormat:@"I am cell %d", indexPath.row]];

回答1:


setText is indeed deprecated. Use textLabel setText instead:

cell.textLabel.text = [NSString stringWithFormat:@"I am cell %d", indexPath.row];



回答2:


When you get a deprecated warning, just alt+click on the method or property that triggered it and you will get basic info about it from documentation inside a popover view, including a property or method you should use instead.



来源:https://stackoverflow.com/questions/7220689/settext-is-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!