2017-09-15 202 views

回答

2

你可以得到名稱,撥號代碼,圖標等在Country list,調用這個API,你將有一個值列表,JSON形式

[[NSURLSession sharedSession] dataTaskWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://restcountries.eu/rest/v2/all"]] 
             completionHandler: 
    ^(NSData *data, NSURLResponse *response, NSError *error) { 
     // ... 
     //handle your data here 
    }] resume]; 

讀取本地JSON文件

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Country" ofType:@"json"]; 
NSData *data = [NSData dataWithContentsOfFile:filePath]; 
NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]; 

JSON文件的URL https://drive.google.com/file/d/0B7iyUiCdVAr3ZVZKUEF4YVk4TFU/view?usp=sharing

將文件拖放到您的應用程序中並使用它,如果您不想使用api。

+0

它是公開的個人。它始終工作@ karthikeyan謝謝 – vikas

+0

亞這是幫助我,但我需要問之前執行。它是公共的雅沒有@karthikeyan – vikas

+0

它是公共API只有你可以實現它或調用它一旦存儲它的數據庫,以後你從DB – karthikeyan