次のコードは、私が個別に呼び出しているメソッドの結果を示しています。JSONValueを使用してメソッドの内容を表示するにはどうすればよいですか?
実際には、特定のメソッド(たとえば、Loan
メソッド)を呼び出す必要があり、このメソッドのすべての内容を表示する必要があります。
私は以下のコードでどのような変更を行う必要がありますか?
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[connection release];
NSString *responseString = [[NSString alloc] initWithData:dataWebService encoding:NSUTF8StringEncoding];
self.dataWebService = nil;
NSArray* latestLoans = [(NSDictionary*) [responseString JSONValue] objectForKey:@"loans"];
[responseString release];
NSDictionary* loan = [latestLoans objectAtIndex:0];
//fetch the data
NSNumber* fundedAmount = [loan objectForKey:@"funded_amount"];
NSNumber* loanAmount = [loan objectForKey:@"loan_amount"];
float outstandingAmount = [loanAmount floatValue] - [fundedAmount floatValue];
NSString* name = [loan objectForKey:@"name"];
NSString* country = [(NSDictionary*)[loan objectForKey:@"location"] objectForKey:@"country"];
//set the text to the label
label.numberOfLines = 0;
label.text = [NSString stringWithFormat:@"Latest loan: %@ \n \n country: %@ \n \n amount $%.2f", name,country,outstandingAmout ];
}
ありがとうございました。私の質問は、メソッドの文字列ローンを書くことなくだった...ちょうどメソッド "ローン"を呼び出すと私たちは "ローンメソッド"に存在するすべてのデータを取得することはできません私は、レスポンスストレスから「ローンメソッド」のコンテンツを取得する – Abhilash