我有一个家长班和Networking
两个孩子。网络有公共和. 我需要从子类中访问它们,但是以线程安全的方式,因为操作将在单独的线程中进行。Upload : Networking
Download : Networking
@property (readonly) BOOL isExecuting;
@property (readonly) BOOL isDone;
什么是优雅的实现方式?谢谢!
编辑:所以我得到它正确吗?这是 Upload.m 的示例
#import "Upload.h"
#import "Networking.h"
@interface Upload ()
@property (assign) BOOL isExecuting;
@end
@implementation Upload
- (void) setIsExecuting:(BOOL)isExecuting{
@synchronized (self) {
_isExecuting = isExecuting;
}
}