The web: web views and internet protocols in Objective-C

Creation QR Code JIS X 0510 in Objective-C The web: web views and internet protocols

The web: web views and internet protocols
Encoding QR Code 2d Barcode In Objective-C
Using Barcode printer for iPhone Control to generate, create QR Code image in iPhone applications.
www.OnBarcode.com
Print UCC - 12 In Objective-C
Using Barcode drawer for iPhone Control to generate, create GS1 128 image in iPhone applications.
www.OnBarcode.com
This chapter covers
Barcode Printer In Objective-C
Using Barcode drawer for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
Barcode Creator In Objective-C
Using Barcode generation for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
Using web views Parsing XML Accessing other protocols
Code 3 Of 9 Generation In Objective-C
Using Barcode creation for iPhone Control to generate, create Code-39 image in iPhone applications.
www.OnBarcode.com
Barcode Encoder In Objective-C
Using Barcode creator for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
We started this book with a look at the web. s 3 through 8 offered an extensive discussion of building iPhone web apps using HTML, CSS, JavaScript, and the dynamic programming language of your choice. As we said at the time, web development is one of two major ways that you can program for the iPhone, the other being the SDK that we ve spent the last ten chapters on. We ve generally suggested web apps as the proper platform for creating internet-related programs. This chapter will present some solutions for when that s not the case. Even if you re depending heavily on the web, there are numerous reasons that you might want to program using the SDK. You might want to make use of its more extensive graphic capabilities. You could be designing something of sufficient complexity that you want to use a well-organized object-oriented environment. You might want to monetize your app without having to depend on ads. For whatever
EAN-13 Supplement 5 Drawer In Objective-C
Using Barcode drawer for iPhone Control to generate, create EAN13 image in iPhone applications.
www.OnBarcode.com
EAN8 Creation In Objective-C
Using Barcode creator for iPhone Control to generate, create EAN-8 Supplement 2 Add-On image in iPhone applications.
www.OnBarcode.com
Low-level networking
Making QR Code JIS X 0510 In Java
Using Barcode maker for BIRT reports Control to generate, create QR Code ISO/IEC18004 image in BIRT reports applications.
www.OnBarcode.com
Print Denso QR Bar Code In Java
Using Barcode creator for Java Control to generate, create Denso QR Bar Code image in Java applications.
www.OnBarcode.com
reason, you ve decided to design an SDK web app, not an HTML-based web app, and now you need to know how to do so. In this chapter, we re going to cover the major ways to access the internet from the SDK. You can do so in a variety of ways, and we ll outline their hierarchy in our first section.
Encode EAN13 In None
Using Barcode drawer for Font Control to generate, create EAN-13 image in Font applications.
www.OnBarcode.com
Making Code 128 Code Set A In Java
Using Barcode generation for Java Control to generate, create Code 128 Code Set A image in Java applications.
www.OnBarcode.com
20.1 The hierarchy of the internet
Generating PDF-417 2d Barcode In .NET Framework
Using Barcode maker for ASP.NET Control to generate, create PDF417 image in ASP.NET applications.
www.OnBarcode.com
Barcode Printer In Java
Using Barcode generation for BIRT Control to generate, create Barcode image in BIRT reports applications.
www.OnBarcode.com
internet programming involves a hierarchy of protocols. At the lowest level, you have the sockets that you use to connect from one computer to another. Above them are a variety of more sophisticated technologies, such as FTP, Bonjour, and HTML. HTML is a critical protocol, represented on the iPhone by both low-level access and the highlevel UIWebView. Recently an increasing number of protocols have been built on top of HTML, forming what we call the social network. This hierarchy of internet protocols is shown in figure 20.1, along with iPhone OS classes of note.
Barcode Printer In None
Using Barcode printer for Microsoft Word Control to generate, create Barcode image in Office Word applications.
www.OnBarcode.com
Barcode Printer In Java
Using Barcode printer for BIRT Control to generate, create Barcode image in Eclipse BIRT applications.
www.OnBarcode.com
Low-level Networking
Encoding PDF-417 2d Barcode In None
Using Barcode creator for Font Control to generate, create PDF417 image in Font applications.
www.OnBarcode.com
ECC200 Creator In Java
Using Barcode creation for Android Control to generate, create Data Matrix 2d barcode image in Android applications.
www.OnBarcode.com
BSD sockets
Generating Code 128C In C#.NET
Using Barcode generation for VS .NET Control to generate, create Code 128 image in Visual Studio .NET applications.
www.OnBarcode.com
USS-128 Drawer In Java
Using Barcode generator for Android Control to generate, create UCC.EAN - 128 image in Android applications.
www.OnBarcode.com
CFNetworking
Unabstracted protocols
Raw HTML access Raw Host Connections
CFHost CFHTTPMessage NSData NSURLRequest
Web views
Abstracted HTML display
UIWebView
Web protocols
Social networking Ajax, JSON, RSS, SOAP, XML
NSXMLParser Third-Party libraries
internet protocols are arranged in a hierarchy.
In this chapter, we re going to cover all of these protocols, starting with the lowest level, but our real focus will be on the higher-level internet and social network protocols, because they re the protocols that are best supported by the iPhone, and they re the ones you re most likely to want to interact with.
20.2 Low-level networking
We ve opted not to pay much attention to BSD sockets and the lower-level networking classes, because we expect they ll be of little interest to most iPhone programmers. If you need to work with BSD sockets, you should look at Apple s Introduction to CFNetwork Programming Guide.
The web: web views and internet protocols
If you need to work with the lower-level protocols, CFNetwork provides a variety of classes that you ll find useful. You can find more information on them in the Networking & internet topic in the Apple docs. In particular, the CFNetwork Framework Reference will give you an overview of the various classes. Among the classes are CFFTPStream, which lets you communicate with FTP servers, and CFNetServices, which gives you access to Bonjour Apple s service discovery protocol. There are also two low-level HTTP-related classes, CFHTTPMessage and CFHTTPStream. We re going to leave these classes alone, as our HTML work will be related to the higher-level NSURL, NSURLRequest, UIWebView, NSMutableURLRequest, and NSURLConnection classes. Rather than skipping over these low-level and unabstracted protocols entirely, we ll take a look at one of them, CFHost. It s the easiest to work with and perhaps the most immediately useful.
20.2.1 The CFHost class
CFHost allows your program to request information about an internet host, such as its
name, its address, and whether it s reachable. Listing 20.1 shows a sample of how to determine whether a host name exists or not.
Listing 20.1 A simple host name lookup
-(IBAction)reportStatus:(id)sender { CFStreamError errorTest; if (myInput.text) { CFHostRef myHost = CFHostCreateWithName(kCFAllocatorDefault, (CFStringRef)myInput.text);
if (myHost) { if (CFHostStartInfoResolution(myHost, kCFHostAddresses, &errorTest)) {
myOutput.text = [myInput.text stringByAppendingString: @" COULD be resolved."]; } else { myOutput.text = [myInput.text stringByAppendingFormat: @" could NOT be resolved (Error: %i).", errorTest.error]; } } CFRelease(myHost); } }
Our sample method, reportStatus:, is activated by a button push. It reads a host name from a UITextField called myInput and reports out to a UITextView called myOutput. All uses of the CFHost commands follow the same pattern. First you create a CFHostRef object with CFHostCreateCopy, CFHostCreateWithAddress, or CFHostCreateWithName B. Then you use CFHostStartInfoResolution to request a certain
Copyright © OnBarcode.com . All rights reserved.