This document describes how to use NSBundle of the iPhone, ASINetworkQueue asynchronous queue of the IPhone, and Settings for the IPhone, let's take a look at this article.
Use of NSBundle for IPhone
The NSBundle object can obtain the attachment of the application installation directory.
The attachment contains all files in the current application. Images, attribute lists, etc)
Get XML file
- NSString *filePath = [[NSBundle mainBundle] pathForResouse:@"re" ofType:@"xml"];
- NSData *data = [[NSData alloc] initWithContentsOfFile:filePath];
Get attribute list
- NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]
- pathForResource:@"ViewControllers" ofType:@"plist"]];
ASINetworkQueue asynchronous queue for IPhone
Using NSOperationQueue (or ASINetWorkQueue, see the following example) will give you more control over asynchronous requests. When a queue is used, only a specified number of requests can be run simultaneously. If the request you added exceeds the maxConcurrentOperationCount attribute of the queue, the request will run after other requests are completed.
NOTE: For the ASINetworkQueue class, see Introduction to the previous IPhone ASIHTTPRequest
- // ASINetworkQueue queue = [ASINetworkQueue alloc] init];
- For (ForumItem * item in itemList)
- {
- // Address of the item. Image
- If (item. Image)
- {
- ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL: [NSURLURLWithString: item. Image];
- Request. userInfo = [NSDictionary dictionaryWithObject: item. ImageforKey: @ "Image"];
- [Request setDelegate: self];
- [Request setDidFinishSelector: @ selector (requestDidFinished :)];
- [Queue addOperation: request];
- }
- }
- [Queue go];
Release Notes: queue
Getting Settings for IPhone
In the IPhone, you can use the NSUserDefaults class to read user settings. NSUserDefaults only one instance is running in the tip application. The Code is as follows:
The Key value is the Key value in Root. plist.
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [defaults objectForKey:@"username"];
- [defaults objectForKey:@"password"];
- [defaults objectForKey:@"protocol"];
- [defaults objectForKey:@"warp"];
- [[defaults objectForKey:@"warpFactor"] stringValue];
Summary:IPhone applicationsAfter learning about development, this article describesIPhoneUse of NSBundle,IPhoneASINetworkQueueAsynchronous queue,IPhoneTo get the Settings.