IPhone application development

Source: Internet
Author: User

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

 
 
  1. NSString *filePath = [[NSBundle mainBundle] pathForResouse:@"re" ofType:@"xml"];  
  2. NSData *data = [[NSData alloc] initWithContentsOfFile:filePath];   

Get attribute list

 
 
  1. NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]   
  2. 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

 
 
  1. // ASINetworkQueue queue = [ASINetworkQueue alloc] init];
  2. For (ForumItem * item in itemList)
  3. {
  4. // Address of the item. Image
  5. If (item. Image)
  6. {
  7. ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL: [NSURLURLWithString: item. Image];
  8. Request. userInfo = [NSDictionary dictionaryWithObject: item. ImageforKey: @ "Image"];
  9. [Request setDelegate: self];
  10. [Request setDidFinishSelector: @ selector (requestDidFinished :)];
  11. [Queue addOperation: request];
  12. }
  13. }
  14. [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.

 
 
  1. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];  
  2. [defaults objectForKey:@"username"];  
  3. [defaults objectForKey:@"password"];  
  4. [defaults objectForKey:@"protocol"];  
  5. [defaults objectForKey:@"warp"];  
  6. [[defaults objectForKey:@"warpFactor"] stringValue];  

Summary:IPhone applicationsAfter learning about development, this article describesIPhoneUse of NSBundle,IPhoneASINetworkQueueAsynchronous queue,IPhoneTo get the Settings.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.