第41条: 多用派发队列,少用同步锁同步锁:@synchronized(self)
_syncQueue = dispatch_ queue_ create ('com. Effectiveobj ectivec. SyncQueue', NULL);
- (NSString*) someString {
__block NSString *local SomeString;
dispatch_ sync (_ syncQueue, ^{
localSomeString =_ someString;
});
return local SomeString;
}
- (void) setSomeString: (NSString*) someString {
dispatch_barrier_async(_syncQueue,, ^{
_someString = someString;
});
}