サーバーから天気予報アプリケーションの緯度、経度の値の応答を取得する

user3182143

天気予報アプリケーションの応答を取得するコーディングを行いました。正確な緯度、経度、母集団の値を取得できませんでした。正確な値ではなく、nullとして応答を取得しています。その後、他の応答を取得できません。また、応答は-> "キャッチされなかった例外 'NSRangeException'が原因でアプリを終了しています、理由: ' * -[__ NSArrayM objectAtIndex:]:インデックス1が境界を超えています[0 .. 0]'"配列インデックス形式で何か間違ったことをしました。すべての値?

これは私のコーディングです

.Mパート

-(void)viewDidLoad

 {

 [super viewDidLoad];

 NSMutableURLRequest *request =[[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:@"http://api.worldweatheronline.com/free/v1/search.ashx?query=London&num_of_results=3&format=json&key=xkq544hkar4m69qujdgujn7w"]];

 [request setHTTPMethod:@"POST"];

 NSError *err;

 NSURLResponse *response;

 NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];

 NSDictionary *dict1 =[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&err];

//NSDictionary *dict1a =[dict1 objectForKey:@"JSON"];

 NSDictionary *dict2 = [dict1 objectForKey:@"search_api"];

 NSArray *array1 =[dict2  objectForKey:@"result"];

 for(int i=0;i<[array1 count]; i++)
 {

    NSDictionary *dict3 =[array1 objectAtIndex:i];

    NSArray *array2 =[dict3 objectForKey:@"areaName"];

    NSDictionary  *dict4 =[array2 objectAtIndex:i];

    // NSArray *arr3 =[dict4 objectForKey:@"London"];

   //manage.transformName= [NSString stringWithFormat:@"%@",[venueNem objectForKey:@"username"]];

      NSString *str1= [NSString stringWithFormat:@"%@",[dict4 objectForKey:@"value"]];

      NSLog(@"the response ==%@",str1);

      NSArray *array3 =[dict3 objectForKey:@"country"];


      NSDictionary *dict5 =[array3 objectAtIndex:i];


      NSString *str2 =[NSString stringWithFormat:@"%@",[dict5 objectForKey:@"value"]];

      NSLog(@"the response ==%@",str2);

      NSString *str3 =[NSString stringWithFormat:@"%@",[dict5 objectForKey:@"latitude"]];

      NSLog(@"the response ==%@",str3);

      NSString *str4 =[NSString stringWithFormat:@"%@",[dict5 objectForKey:@"longitude"]];

      NSLog(@"the response ==%@",str4);

      NSString *str5 = [NSString stringWithFormat:@"%@",[dict5 objectForKey:@"population"]];

      NSLog(@"the response ==%@",str5);

      NSArray *arr4 =[dict3 objectForKey:@"region"];

      NSDictionary *dict6 =[arr4 objectAtIndex:i];

      NSString *str6 = [NSString stringWithFormat:@"%@",[dict6 objectForKey:@"value"]];

      NSLog(@"the response ==%@",str6);

      NSArray *arr5 =[dict3 objectForKey:@"weatherUrl"];

      NSDictionary *dict7 =[arr5 objectAtIndex:i];

      NSString *str7 =[NSString stringWithFormat:@"%@",[dict7 objectForKey:@"value"]];

      NSLog(@"the response ==%@",str7);

  }

 for(int j=0;j<[array1 count];j++)
 {

    NSDictionary *dict8 =[array1 objectAtIndex:j];

    NSArray *arr6 =[dict8 objectForKey:@"areaname"];

    NSDictionary *dict9 =[arr6 objectAtIndex:j];

    NSString *str8 =[NSString stringWithFormat:@"%@",[dict9 objectForKey:@"value"]];

    NSLog(@"the response ==%@",str8);

    NSArray *arr7 =[dict8 objectForKey:@"country"];

    NSDictionary *dict10 =[arr7 objectAtIndex:j];

    NSString *str9 =[NSString stringWithFormat:@"%@",[dict10 objectForKey:@"value"]];

    NSLog(@"the response ==%@",str9);

    NSString *str10 =[NSString stringWithFormat:@"%f",[dict10 objectForKey:@"latitude"]];

    NSLog(@"the response ==%@",str10);

    NSString *str11 =[NSString stringWithFormat:@"%f",[dict10 objectForKey:@"longitude"]];

   NSLog(@"the response ==%@",str11);

   NSString *str12 =[NSString stringWithFormat:@"%d",[dict10 objectForKey:@"population"]];

   NSLog(@"the response ==%@",str12);

   NSArray  *arr8 =[dict8 objectForKey:@"region"];

   NSDictionary *dict11 =[arr8 objectAtIndex:j];


   NSString *str13 =[NSString stringWithFormat:@"%@",[dict11 objectForKey:@"value"]];

   NSLog(@"the response ==%@",str13);

   NSArray *arr9 =[dict8 objectForKey:@"weatherurl"];

   NSDictionary *dict12 =[arr9 objectAtIndex:j];

   NSString *str14 =[NSString stringWithFormat:@"%@",[dict12 objectForKey:@"value"]];

   NSLog(@"the response ==%@",str14);
}

 NSDictionary *dict13 =[array1 objectAtIndex:2];

 NSArray *arr10 =[dict13 objectForKey:@"areaname"];

 NSDictionary *dict14 =[arr10 objectAtIndex:2];

 NSString *str15 =[NSString stringWithFormat:@"%@",[dict14 objectForKey:@"value"]];

 NSLog(@"the response ==%@",str15);

 NSArray *arr11 =[dict13 objectForKey:@"country"];

 NSDictionary *dict15 =[arr11 objectAtIndex:2];

 NSString *str16 =[NSString stringWithFormat:@"%@",[dict15 objectForKey:@"value"]];

 NSLog(@"the response ==%@",str16);

 NSString *str17 =[NSString stringWithFormat:@"%f",[dict15 objectForKey:@"latitude"]];

 NSLog(@"the response ==%@",str17);

 NSString *str18 =[NSString stringWithFormat:@"%f",[dict15 objectForKey:@"longitude"]];

 NSLog(@"the response ==%@",str18);

 NSString *str19 =[NSString stringWithFormat:@"%d",[dict15 objectForKey:@"population"]];

 NSLog(@"the response ==%@",str19);

 NSArray  *arr12 =[dict13 objectForKey:@"region"];

 NSDictionary *dict16 =[arr12 objectAtIndex:2];

 NSString *str20 =[NSString stringWithFormat:@"%@",[dict16 objectForKey:@"value"]];

 NSLog(@"the response ==%@",str20);

 NSArray *arr13 =[dict13 objectForKey:@"weatherurl"];

 NSDictionary *dict17 =[arr13 objectAtIndex:2];

 NSString *str21 =[NSString stringWithFormat:@"%@",[dict17 objectForKey:@"value"]];

 NSLog(@"the response ==%@",str21); }
Anbu.Karthik
 arra=[[NSMutableArray alloc]init];

NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://api.worldweatheronline.com/free/v1/search.ashx?query=London&num_of_results=3&format=json&key=xkq544hkar4m69qujdgujn7w"]];

[request setHTTPMethod:@"GET"];

[request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"content-type"];

NSError *err;
NSURLResponse *response;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];

NSDictionary *jsonArray = [NSJSONSerialization JSONObjectWithData:responseData options: NSJSONReadingMutableContainers error: &err];

NSArray *array=[[jsonArray objectForKey:@"search_api"]objectForKey:@"result"];

for (int i=0; i<[array count]; i++) {


    NSLog(@"the areaName==%@",[[[[array objectAtIndex:i]objectForKey:@"areaName"]objectAtIndex:0]objectForKey:@"value"]);
    NSLog(@"the country==%@",[[[[array objectAtIndex:i]objectForKey:@"country"]objectAtIndex:0]objectForKey:@"value"]);
    NSLog(@"the latitude==%@",[[array objectAtIndex:i]objectForKey:@"latitude"]);
    NSLog(@"the long==%@",[[array objectAtIndex:i]objectForKey:@"longitude"]);
    NSLog(@"the pop==%@",[[array objectAtIndex:i]objectForKey:@"population"]);

    NSLog(@"the region==%@",[[[[array objectAtIndex:i]objectForKey:@"region"]objectAtIndex:0]objectForKey:@"value"]);
    NSLog(@"the url==%@",[[[[array objectAtIndex:i]objectForKey:@"weatherUrl"]objectAtIndex:0]objectForKey:@"value"]);

  NSString *areaName=[[[[array objectAtIndex:i]objectForKey:@"areaName"]objectAtIndex:0]objectForKey:@"value"];
    [arra addObject:areaName];
 }

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Android アプリからサーバーに緯度と経度を送信する

分類Dev

ReactNativeのGoogleプレイスオートコンプリートから緯度と経度を取得する

分類Dev

天気予報アプリケーションで天気予報アイコンを使用するにはどうすればよいですか

分類Dev

緯度経度Javaから国のアイソコードを取得する

分類Dev

画像から緯度と経度の情報を取得する方法

分類Dev

特定の国のすべてのロケーションポイント(緯度と経度)を取得する方法はありますか?

分類Dev

緯度と経度を持つmysqlアドレステーブルから緯度と経度からの距離を取得する方法

分類Dev

データフレームの列から緯度と経度を取得する

分類Dev

1番目のアクティビティ緯度経度のジオロケーションを取得するための2番目のアクティビティ。情報を最初のアクティビティに戻す方法は?

分類Dev

SQLサーバーで緯度と経度の値をdmsからddに変換します

分類Dev

Railsでサードパーティアプリケーションからの応答を転送する

分類Dev

アプリがReactNativeのバックグラウンドである場合にサービスの緯度と経度を更新する方法

分類Dev

緯度と経度の空港のリストを返すストアドプロシージャを作成する

分類Dev

すべてのFirebaseドキュメントから緯度と経度のデータを取得する

分類Dev

グーグルマップの方向APIから緯度と経度の配列を取得する方法

分類Dev

PostGISで指定された緯度/経度のラスターからアスペクトを取得する

分類Dev

天気予報をスタートアップアプリケーションに追加するにはどうすればよいですか?

分類Dev

位置情報(緯度/経度)を含む写真をサーバーにアップロードする

分類Dev

ViewComponentASP.Coreサーバーの応答を受信するAngular4アプリケーション

分類Dev

Androidの地図のデータベースからパスの緯度と経度の値を描画する方法

分類Dev

各経度と緯度のラスター平均を取得する

分類Dev

値でグループ化し、T-SQLの各グループのポイント(緯度と経度)から地理ポリラインを作成します

分類Dev

iOS:データが応答としてWebサービスから送信されている場合、複数の経度と緯度の場所名を取得するにはどうすればよいですか?

分類Dev

Googleマーカーからの緯度/経度の取得

分類Dev

overpassAPIのノードIDから緯度と経度を取得します

分類Dev

変数を別のアプリケーションに送信し、そこから応答を取得しますか?

分類Dev

マップビューの特定のポイントから経度と緯度をすばやく取得するにはどうすればよいですか?

分類Dev

Androidのジオロケーション印刷の緯度と経度

分類Dev

ジオコーダー値からnsmutablearrayに緯度と経度の値を追加する方法は?

Related 関連記事

  1. 1

    Android アプリからサーバーに緯度と経度を送信する

  2. 2

    ReactNativeのGoogleプレイスオートコンプリートから緯度と経度を取得する

  3. 3

    天気予報アプリケーションで天気予報アイコンを使用するにはどうすればよいですか

  4. 4

    緯度経度Javaから国のアイソコードを取得する

  5. 5

    画像から緯度と経度の情報を取得する方法

  6. 6

    特定の国のすべてのロケーションポイント(緯度と経度)を取得する方法はありますか?

  7. 7

    緯度と経度を持つmysqlアドレステーブルから緯度と経度からの距離を取得する方法

  8. 8

    データフレームの列から緯度と経度を取得する

  9. 9

    1番目のアクティビティ緯度経度のジオロケーションを取得するための2番目のアクティビティ。情報を最初のアクティビティに戻す方法は?

  10. 10

    SQLサーバーで緯度と経度の値をdmsからddに変換します

  11. 11

    Railsでサードパーティアプリケーションからの応答を転送する

  12. 12

    アプリがReactNativeのバックグラウンドである場合にサービスの緯度と経度を更新する方法

  13. 13

    緯度と経度の空港のリストを返すストアドプロシージャを作成する

  14. 14

    すべてのFirebaseドキュメントから緯度と経度のデータを取得する

  15. 15

    グーグルマップの方向APIから緯度と経度の配列を取得する方法

  16. 16

    PostGISで指定された緯度/経度のラスターからアスペクトを取得する

  17. 17

    天気予報をスタートアップアプリケーションに追加するにはどうすればよいですか?

  18. 18

    位置情報(緯度/経度)を含む写真をサーバーにアップロードする

  19. 19

    ViewComponentASP.Coreサーバーの応答を受信するAngular4アプリケーション

  20. 20

    Androidの地図のデータベースからパスの緯度と経度の値を描画する方法

  21. 21

    各経度と緯度のラスター平均を取得する

  22. 22

    値でグループ化し、T-SQLの各グループのポイント(緯度と経度)から地理ポリラインを作成します

  23. 23

    iOS:データが応答としてWebサービスから送信されている場合、複数の経度と緯度の場所名を取得するにはどうすればよいですか?

  24. 24

    Googleマーカーからの緯度/経度の取得

  25. 25

    overpassAPIのノードIDから緯度と経度を取得します

  26. 26

    変数を別のアプリケーションに送信し、そこから応答を取得しますか?

  27. 27

    マップビューの特定のポイントから経度と緯度をすばやく取得するにはどうすればよいですか?

  28. 28

    Androidのジオロケーション印刷の緯度と経度

  29. 29

    ジオコーダー値からnsmutablearrayに緯度と経度の値を追加する方法は?

ホットタグ

アーカイブ