Came across an SDK3.0 deprecation that I am having a bit of trouble trying to figure out. If my declaration of
遇到了SDK3.0的弃用,我在尝试弄清楚时遇到了一些麻烦。如果我的声明
@property (nonatomic, retain) UIImage *rowImage;
does not work, nor
不起作用,也不起作用
@property (nonatomic, readonly, retain) UIImage *rowImage;
and I
@synthesize rowImage;
Do I need to write my own setter because @synthesize
will not properly handle this?
我是否需要编写自己的setter,因为@synthesize无法正确处理这个问题?
<hr>
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:RootViewControllerCell] autorelease];
// Dpericated in SDK 3.0 <br>
//<br>
//cell.text = controller.title;<br>
//cell.image = controller.rowImage;<br>
// Using what the documentation says to use
Error===> cell.textLabel = controller.title;<br>
Error===> cell.imageView = controller.rowImage;<br>
Error: Object cannot be set - Either readonly property or no setter found.
Hope this makes sense, any help would be appreciated.
希望这是有道理的,任何帮助将不胜感激。
2 个解决方案
#1
You can also use the usual .-syntax:
您也可以使用通常的。-syntax:
cell.textLabel.text = controller.title;
#2
Use the non-deprecated:
使用未弃用的:
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RootViewControllerCell] autorelease];
Then:
[[cell textLabel] setText:[controller title]]; <br>
[[cell imageView] setImage:[controller rowImage]];
#1
You can also use the usual .-syntax:
您也可以使用通常的。-syntax:
cell.textLabel.text = controller.title;
#2
Use the non-deprecated:
使用未弃用的:
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RootViewControllerCell] autorelease];
Then:
[[cell textLabel] setText:[controller title]]; <br>
[[cell imageView] setImage:[controller rowImage]];