13.07.2015 Views

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

286CHAPTER 9: Writing an ApplicationNSMutableSet *NSMutableSet *_clients;_remoteAddressBooks;}// NSNetService name string to handler blocks// this uses a map table so we can specify copy semantics for valuesNSMapTable *_serviceResolutionHandlers;- (id) init{self = [super init];if ( self == nil )return ( nil );_servicesByDomain = [NSMutableDictionary new];_serviceResolutionHandlers = [[NSMapTable alloc]initWithKeyOptions: NSPointerFunctionsObjectPersonality|NSPointerFunctionsCopyInvalueOptions: NSPointerFunctionsObjectPersonality|NSPointerFunctionsCopyIncapacity: 0];_clients = [NSMutableSet new];_remoteAddressBooks = [NSMutableSet new];_browser = [NSNetServiceBrowser new];[_browser setDelegate: self];[_browser searchForServicesOfType: @"_apad._tcp" inDomain: @""];}return ( self );- (void) dealloc{[_serverSocket close];[_browser stop];[_servicesByDomain enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop){[obj makeObjectsPerformSelector: @selector(stop)];}];}...@endThere’s plenty to see here. First of all you’ve attached the member variables to the@implementation statement to keep them private. Right there you see the net service browserobject and the storage for the located services. The services are broken up by domain sinceiCloud Back To My Mac users will see services advertised both on the local network and via theBack To My Mac service. Breaking them up by service will allow you to prefer the local instancerather than funneling everything through Apple’s address translation servers.Next are the variables used for vending the local address book: the proxy object used to obtaindata, the communications socket, and the NSNetService through which the service is published.www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!