2011-07-05 28 views
9

NSLocale'den birkaç bilgi (geçerli ülke, ülke adı) alan bu kod parçam var. [: Değeri: yerel displayNameForKey] hiç çalışmıyor ama hiçbir uyarıları ve hataları vardı onu kontrol üzerine iOS 5.iOS'ta Yerel Konumları Alma 5

yılında

O iOS 4.3 sorunsuz çalışıyor ancak çöker [yerel LocaleIdentifier] ve görünüyor onu inşa ederken tespit edildi.

iOS 5'te çalışmak için ne yapabilirim?

// Create a pool for autoreleased objects 

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 

    // Get the current country and locale information of the user 
    NSLocale *locale = [NSLocale currentLocale]; 
    NSString *currentLocaleID = [locale localeIdentifier]; //returns en_US instead of the actual country stored in phone settings 
    NSDictionary *localeDictionary = [NSLocale componentsFromLocaleIdentifier:currentLocaleID];  
    NSString *currentCountry = [locale displayNameForKey:NSLocaleCountryCode 
                value:[localeDictionary objectForKey:NSLocaleCountryCode]];  // returns nil 

    // Get the list of country codes 
    NSArray *countryCodeArray = [NSLocale ISOCountryCodes]; 
    NSMutableArray *sortedCountryNameArray = [NSMutableArray array]; 


    for (NSString *countryCode in countryCodeArray) { 
     NSString *displayNameString = [locale displayNameForKey:NSLocaleCountryCode value:countryCode]; //displayNameString is nil after executing this line 
     [sortedCountryNameArray addObject:displayNameString]; //app crashes here 
    } 

    // Drain the autoreleased pool 
    [pool drain]; 
+2

nedeniyle NDA henüz burada iOS5 sorulara cevap veremez. Apple Developer Forumlarında sorun ve/veya Apple ile bir RADAR bileti açın. –

cevap

2

Bu iOS 5.1 'de çökmez veya 5.1.1

İlgili konular