2011-07-05 2 views
9

NSLocaleからいくつかの情報(現在の国名、国名)を取得するこのコードがあります。iOS 5でのロケーションの取得

それは[ロケールlocaleIdentifier]と[ロケールdisplayNameForKey:値:]と思われるチェックの際のiOS 4.3で問題なく動作しますが、iOSの5のクラッシュ

全く動作しませんが、何の警告やエラーがなかったですそれを構築中に検出されました。

iOS 5で動作させるにはどうすればよいですか?

// 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

にクラッシュしていません。アップルデベロッパーフォーラムで質問してください。また、アップルのバグとしてRADARチケットを開くこともできます。 –

答えて

2

これは、我々が原因NDAのはまだここにiOS5を質問に答えることができないのiOS 5.1または5.1.1

関連する問題