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
- NSUserDefaults * defs = [NSUserDefaults standardUserDefautls];
- // Obtain the default value.
- NSArray * ages = [defs objectForKey: @ "AppleLanguages"];
- // Find AppleLanguages in the default value. The returned value is an array.
- NSString * preferredLang = [ages objectAtIndex: 0];
- // 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.
- ABAddressBookRef addressBook = ABAddressBookCreate ();
- Required learray = (NSMutableArray *) ABAddressBookCopyArrayOfAllPeople (addressBook );
- For (id * people in each learray)
- {
- ABMultiValueRef phones = (ABMultiValueRef) ABRecordCopyValue (people, kABPersonPhoneProperty );
- Int nCount = ABMultiValueGetCount (phones );
- For (int I = 0; I <nCount; I ++)
- {
- NSString * phonelLable = (NSString *) ABMultiValueCopyLabelAtIndex (phones, I );
- NSString * phoneNO = (NSString *) ABMultiValueCopyValueAtIndex (phones, I); // This is the phone number.
- }
- }
3. Code for adding music to cocos2d for iphone application development
Add music code in cocos2d, provided by coachina member "ljg420811"
- NSString *path = [[NSBundle mainBundle] pathForResource:@"testmusic2" ofType:@"wav"];
- SystemSoundID soundID;
- AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
- AudioServicesPlaySystemSound (soundID);
Summary:IPhone applicationsThe content of the development and learning notes implementation case has been introduced. I hope this article will help you!