草庐IT

fruitCount

全部标签

ios - getter 和 setter 不工作 objective-c

我不能在objective-c中这样做吗?@interfaceFoo:NSObject{intapple;intbanana;}@propertyintfruitCount;@end@implementationFoo@synthesizefruitCount;//withoutthiscompilererrorswhentryingtoaccessfruitCount-(int)getFruitCount{returnapple+banana;}-(void)setFruitCount:(int)value{apple=value/2;banana=value/2;}@end我正在使