I was just reading some source code of https://github.com/MugunthKumar/MKNetworkKit, and saw this
+(void) initialize {
if(!_sharedNetworkQueue) {
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedNetworkQueue = [[NSOperationQueue alloc] init];
[_sharedNetworkQueue addObserver:[self self] forKeyPath:@"operationCount" options:0 context:NULL];
[_sharedNetworkQueue setMaxConcurrentOperationCount:6];
});
}
}
what does that [self self] mean here?
-selfis a method defined in theNSObjectprotocol. It returns the receiver, that is, the object you send the messageselfto. If you do[a self], you getaback, and yes, if you do[self self](orself.self), you indeed getselfback.It may be useful in key-value paths where you are supposed to append a new component, but intend to observe the entire object, like in Cocoa Bindings. I don’t see any application of this in the code you posted, but it may be the case that proxies adopt
selfdifferently, to point to the proxy itself, rather than the remote/forwarded object.