iPhone应用开发学习笔记实现案例

移动开发 iOS
iPhone应用开发学习笔记实现案例是本文要介绍的内容,主要是来学习iphone应用开发中的一些案例中的技巧学习,具体内容来看本文详解。

iPhone应用开发学习笔记实现案例是本文要介绍的内容,主要是来学习iphone应用开发中的一些案例中的技巧学习,具体内容来看本文详解。

1、获取用户iPhone应用中***语言的方法

  1. NSUserDefaults* defs = [NSUserDefaults standardUserDefautls];  
  2. //得到用户缺省值  
  3.    
  4. NSArray* languages = [defs objectForKey:@"AppleLanguages"];  
  5. //在缺省值中找到AppleLanguages, 返回值是一个数组  
  6.    
  7. NSString* preferredLang = [languages objectAtIndex:0];  
  8. //在得到的数组中的***个项就是用户的***语言了 

2、获取iPhne应用中关于通讯录里电话号码的代码

获取通讯录里电话号码的代码恐怕是很多 iPhone App 需要的功能,下面这段代码由 CocoaChina 会员“fake”提供,希望对苹果开发者有所帮助。

  1. ABAddressBookRef addressBook = ABAddressBookCreate();  
  2. peopleArray = (NSMutableArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);  
  3. for (id *people in peopleArray)  
  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);  // 这个就是电话号码  
  11.         }  

3、iphone应用开发在cocos2d里添加音乐的代码

在 cocos2d 里添加音乐的代码,由 CocoaChina  会员“ljg420811”提供

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

小结:iPhone应用开发学习笔记实现案例的内容介绍完了,希望通过本文的学习能对你有所帮助!

责任编辑:zhaolei 来源: 互联网
相关推荐

2011-08-09 17:29:29

iPhone文件屏幕

2011-08-08 14:57:46

iPhone Autoreleas Property

2011-08-15 15:44:46

iPhone开发PDF

2011-08-18 16:24:44

iPhone开发图片

2011-08-15 18:02:32

iPhone开发表视图

2011-08-19 10:13:05

iPhone开发

2011-08-16 15:48:37

iPhone开发抓图程序

2011-08-12 09:48:24

iPhoneCoreLocatio定位

2011-08-18 15:24:40

iPhone国际化

2011-08-15 10:06:22

iPhone开发nib 文件

2011-08-19 10:05:30

iPhone开发

2011-08-17 16:12:20

iPhone应用程序

2011-08-16 18:13:42

IPhone开发UIView动画

2011-08-08 10:10:14

iPhone开发 图片 方法

2011-08-18 10:39:46

iPhone开发界面

2011-08-05 14:48:06

iPhone应用 异步队列

2011-08-08 15:56:18

iPhone 震动 NSUserDefa

2011-09-05 16:47:49

jQuery Mobi

2011-08-15 17:38:48

iPhone开发调试工具

2011-08-09 17:12:30

iPhoneCFRunLoop
点赞
收藏

51CTO技术栈公众号