【发布时间】:2010-11-09 10:08:29
【问题描述】:
我正在研究“元素”示例应用程序的源代码,我看到在AtomicElement.h 中有四个属性声明为只读:
@property (readonly) UIImage *stateImageForAtomicElementTileView;
@property (readonly) UIImage *flipperImageForAtomicElementNavigationItem;
@property (readonly) UIImage *stateImageForAtomicElementView;
@property (readonly) CGPoint positionForElement;
在实现文件中,它们看起来像
- (UIImage *)stateImageForAtomicElementTileView {
return [UIImage imageNamed:[NSString stringWithFormat:@"%@_37.png",state]];
}
您能否详细说明这样做的原因?为什么不使用类似的东西
- (UIImage*) stateImageForAtomicElementTileView;
在头文件中,然后像[element stateImageForAtomicElementTileView];而不是element.stateImageForAtomicElementTileView一样访问它?
【问题讨论】:
标签: ios properties readonly