iPhone應(yīng)用開發(fā)學(xué)習筆記實現(xiàn)案例
iPhone應(yīng)用開發(fā)學(xué)習筆記實現(xiàn)案例是本文要介紹的內(nèi)容,主要是來學(xué)習iphone應(yīng)用開發(fā)中的一些案例中的技巧學(xué)習,具體內(nèi)容來看本文詳解。
1、獲取用戶iPhone應(yīng)用中***語言的方法
- NSUserDefaults* defs = [NSUserDefaults standardUserDefautls];
- //得到用戶缺省值
- NSArray* languages = [defs objectForKey:@"AppleLanguages"];
- //在缺省值中找到AppleLanguages, 返回值是一個數(shù)組
- NSString* preferredLang = [languages objectAtIndex:0];
- //在得到的數(shù)組中的***個項就是用戶的***語言了
2、獲取iPhne應(yīng)用中關(guān)于通訊錄里電話號碼的代碼
獲取通訊錄里電話號碼的代碼恐怕是很多 iPhone App 需要的功能,下面這段代碼由 CocoaChina 會員“fake”提供,希望對蘋果開發(fā)者有所幫助。
- ABAddressBookRef addressBook = ABAddressBookCreate();
- peopleArray = (NSMutableArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
- for (id *people in peopleArray)
- {
- 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); // 這個就是電話號碼
- }
- }
3、iphone應(yīng)用開發(fā)在cocos2d里添加音樂的代碼
在 cocos2d 里添加音樂的代碼,由 CocoaChina 會員“ljg420811”提供
- NSString *path = [[NSBundle mainBundle] pathForResource:@"testmusic2" ofType:@"wav"];
- SystemSoundID soundID;
- AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
- AudioServicesPlaySystemSound (soundID);
小結(jié):iPhone應(yīng)用開發(fā)學(xué)習筆記實現(xiàn)案例的內(nèi)容介紹完了,希望通過本文的學(xué)習能對你有所幫助!