0
我正在使用AFNetworking來解析一些json並絕對喜歡它。AFNetworking解析json更深
現在我想更深入一個槓桿。我的json輸出看起來像這樣
-result
-0
rezept_id : value1
rezept_name : value2
rezept_zubereitung : value3
一切工作正常,直到在這裏,我可以解析的價值。但現在這樣下去
-rezept_bilder
-0
-bigfix
file : value4
file_path : value5
現在我想解析JSON文件屬性值(值4),並在圖像視圖顯示。要顯示圖像,我會做這樣的事情,如果它將在主要。
[self.restuarantImageView setImageWithURL:[NSURL URLWithString:[self.restuarantDetail objectForKey:@"file"]]];
但我怎麼告訴他,該文件的值不是主無奈之下
-rezept_bilder
-0
- bigfix
這裏是我使用的解析數據到地步,我卡代碼。
-(void)makeRestuarantsRequests3{
NSURL *url = [NSURL URLWithString:@"http://api.chefkoch.de/api/1.0/api-recipe.php? zufall=1&divisor=0&limit=1"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id responseObject) {
self.googlePlacesArrayFromAFNetworking3 = [responseObject objectForKey:@"result"];
NSDictionary *tempDictionary3= [self.googlePlacesArrayFromAFNetworking3 objectAtIndex:0];
self.zubereitung.text = [tempDictionary3 objectForKey:@"rezept_zubereitung"];
self.Name.text = [tempDictionary3 objectForKey:@"rezept_name"];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id responseObject) {
NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);
}];
在此先感謝和抱歉我的英語不好,希望你們明白我的問題所在!
-----------編輯
多虧了它現在的工作:d
你真的治好了我
這是我做的
-(void)makeRestuarantsRequests3{
NSURL *url = [NSURL URLWithString:@"http://api.chefkoch.de/api/1.0/api-recipe.php?zufall=1&divisor=0&limit=1"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id responseObject) {
self.googlePlacesArrayFromAFNetworking3 = [responseObject objectForKey:@"result"];
NSDictionary *tempDictionary3= [self.googlePlacesArrayFromAFNetworking3 objectAtIndex:0];
self.zubereitung.text = [tempDictionary3 objectForKey:@"rezept_zubereitung"];
self.Name.text = [tempDictionary3 objectForKey:@"rezept_name"];
self.googlePlacesArrayFromAFNetworking5 =[tempDictionary3 objectForKey:@"rezept_bilder"];
NSDictionary *tempDictionary4= [self.googlePlacesArrayFromAFNetworking5 objectAtIndex:0];
NSDictionary *tempDictionary5 = [tempDictionary4 objectForKey:@"bigfix"];
[self.Bild setImageWithURL:[NSURL URLWithString:[tempDictionary5 objectForKey:@"file"]]];
感謝您的快速回復。還沒有testet呢,但我認爲你錯過了代碼中的「rezept_bilder」對象? – user2610014
是的,將第1行中的「結果」更改爲「rezept_bilder」。希望您瞭解如何做到這一點! – KishoreK