iOS executing本来是readonly,为什么可以重写成readwrite,不合乎常理啊,为什么?

gaoyuqiang30_1 发布于 2015/11/30 17:28
阅读 1K+
收藏 0

executing本来是readonly,为什么可以重写成readwrite,不合乎常理啊,为什么?


@interface MyOperation()

@property (assign, nonatomic, getter = isExecuting) BOOL executing;

@property (assign, nonatomic, getter = isFinished) BOOL finished;

@property(nonatomic, strong) NSURLRequest *request;

@property(nonatomic, strong) NSURLSession *session;

@property(nonatomic, strong) NSString *threadName;

@end

@implementation MyOperation

@synthesize executing = _executing;

@synthesize finished = _finished;


- (void)setFinished:(BOOL)finished {

    [self willChangeValueForKey:@"isFinished"];

    _finished = finished;

    [self didChangeValueForKey:@"isFinished"];

}

- (void)setExecuting:(BOOL)executing {

    [self willChangeValueForKey:@"isExecuting"];

    _executing = executing;

    [self didChangeValueForKey:@"isExecuting"];

}


加载中
0
爱吃胡萝卜
爱吃胡萝卜

@property (assign, nonatomic, getter = isExecuting) BOOL executing;

哥哥你哪里看到了是readOnly ?不是明明 assign属性

getter = isExecuting 这个只是重命名get 方法。默认的应该是 self.executing 使用这个后就变成self.isExecuting

0
LINAICAI
LINAICAI
差点笑出来了,重写getter而已。。。
返回顶部
顶部