Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In the day-to-day world of iPhone network programming, certain tasks come up over and over again, particularly those dealing with recovering the local iPhone IP address information and working with address structures. Listing 15-3 provides a handful of utilities, several based on Apple sample code, that help you manage these tasks.
As with Recipe 15-1 and Listing 15-2, these methods are wrapped into the UIDevice class as a category extension. They are, again, all implemented as class methods because their utility is not tied to any particular object instance. The methods in this recipe are as follows:
• A pair of methods (stringFromAddress: and addressFromString:) helps you convert address structures to and from string representations. These integrate well with the NSNetService class, allowing you to convert sockaddr structures into NSString instances and back.