市外局番と場所を含むplistファイルを作成しました:areacodes.plist。あなただけのplistファイルを使用しない場合
:それは以下の手順を実行します。使用するには
1.プロジェクトにplistファイルを追加します。
2.ロードファイル:
NSBundle *bundle = [NSBundle mainBundle];
NSString *plistPath = [bundle pathForResource:@"areacodes" ofType:@"plist"];
NSDictionary *areaCodeDict = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
3.はあなたがロードした辞書を使用してください。キーは市外局番あり、値が場所は次のとおりです。
NSString *areaCode = @"801";
NSString *location = [self.areaCodeConversion objectForKey:areaCode];
NSLog(@"%@",location); // prints utah
が含まクラスを使用するには:
1.プロジェクトにダウンロードしたフォルダを追加します。
2. plistの情報にアクセスするために含まクラスを使用します。
#import "AreaCodes.h"
...
AreaCodes *areaCodes = [[AreaCodes alloc] init];
NSString *location = [areaCodes getLocationForCode:@"801"];
NSLog(@"%@",location);
// prints "Utah"
同様の質問は、この1の後に1日頼まれた:http://stackoverflow.com/questions/9284212/how-to -locate-any-mobile-number-using-iphone-application/18930785#18930785 – newenglander