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.

184CHAPTER 6: Networking: Connections, Data, and the Cloudnot only find services on the local network but also advertise your own in only a feweasy steps.Service ResolutionYou can search the network for services of a given type using an instance of theNSNetServiceBrowser class. The service browser object operates asynchronously and sendsmessages to a delegate object on a given run loop as it encounters various events. A browsercan be used to search for available domains either for browsing or registering new services (adomain may be browsable but not support dynamic addition of new items), or it can search adomain for services. The browser’s delegate can implement a number of different methods toreceive updates during the search process, which are outlined in Table 6-2.Table 6-2. NSNetServiceBrowser Delegate MethodsMessage- (void)netServiceBrowserWillSearch:(NSNetServiceBrowser*)browser- (void)netServiceBrowserDidStopSearch:(NSNetServiceBrowser*)browser- (void)netServiceBrowser:(NSNetServiceBrowser*)browserdidNotSearch:(NSDictionary*)errorDict- (void)netServiceBrowser:(NSNetServiceBrowser*)browserdidFindDomain:(NSString*)domainmoreComing:(BOOL)moreComing- (void)netServiceBrowser:(NSNetServiceBrowser*)browserdidFindService:(NSNetService*)servicemoreComing:(BOOL)moreComing- (void)netServiceBrowser:(NSNetServiceBrowser*)browserdidRemoveDomain:(NSString*)domainmoreComing:(BOOL)moreComing- (void)netServiceBrowser:(NSNetServiceBrowser*)browserdidRemoveService:(NSNetService*)servicemoreComing:(BOOL)moreComingDescriptionThe browser sends this message to itsdelegate before it begins any form of searchoperation. If the search cannot start, thedelegate will instead receive a -netServiceBrowser:didNotSearch: message.Sent to the browser’s delegate whenever asearch stops running, whether because allresults have been received or because thebrowser was explicitly stopped.When the browser is unable to begin asearch for some reason, it will send thismessage to its delegate. The supplieddictionary contains two key/value pairsdescribing the error domain and code.Each domain discovered during a search forbrowse or register domains will be reportedto this method. If the passed domain is thelast one, moreComing will be NO.Each service of the requested type foundby the browser is reported to this method.When moreComing is NO, all results havebeen processed.When a domain becomes unavailable, yourdelegate object will be notified through thismethod.When a service becomes unavailable, thismethod will be called to notify your delegateobject of the change.www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!