IPhone Application Development Study Notes implementation case

Source: Internet
Author: User

IPhone applicationsThe development study note implementation case is the content to be introduced in this article, mainly to learnIphone applicationsLearn the skills in some cases during development. For details, refer to this article.

1. Obtain the preferred language of your iPhone application

 
 
  1. NSUserDefaults * defs = [NSUserDefaults standardUserDefautls];
  2. // Obtain the default value.
  3. NSArray * ages = [defs objectForKey: @ "AppleLanguages"];
  4. // Find AppleLanguages in the default value. The returned value is an array.
  5. NSString * preferredLang = [ages objectAtIndex: 0];
  6. // The first item in the obtained array is the user's preferred language.

2. Obtain the phone number code in the address book in the iPhne application.

The code for obtaining phone numbers in the address book may be required by many iPhone apps. The following code is provided by CocoaChina member fake, hoping to help Apple developers.

 
 
  1. ABAddressBookRef addressBook = ABAddressBookCreate ();
  2. Required learray = (NSMutableArray *) ABAddressBookCopyArrayOfAllPeople (addressBook );
  3. For (id * people in each learray)
  4. {
  5. ABMultiValueRef phones = (ABMultiValueRef) ABRecordCopyValue (people, kABPersonPhoneProperty );
  6. Int nCount = ABMultiValueGetCount (phones );
  7. For (int I = 0; I <nCount; I ++)
  8. {
  9. NSString * phonelLable = (NSString *) ABMultiValueCopyLabelAtIndex (phones, I );
  10. NSString * phoneNO = (NSString *) ABMultiValueCopyValueAtIndex (phones, I); // This is the phone number.
  11. }
  12. }

3. Code for adding music to cocos2d for iphone application development

Add music code in cocos2d, provided by coachina member "ljg420811"

 
 
  1. NSString *path = [[NSBundle mainBundle] pathForResource:@"testmusic2" ofType:@"wav"];  
  2. SystemSoundID soundID;  
  3. AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);  
  4. AudioServicesPlaySystemSound (soundID); 

Summary:IPhone applicationsThe content of the development and learning notes implementation case has been introduced. I hope this article will help you!

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.