0
我使用JSON解析器進行解析。我將數據存儲到searchURL
,這是一個NSMutableDictionary
。我得到了一個JSON響應。if中的條件的意外結果,使用&&
ksearchKeyHeadline = "noresults"
ksearchKeyNewsText = "http://172.15.12.98:8080//...... url."
ksearchKeyIssuersText= "noresults"
這裏我提出條件:
if ([[searchURL objectForKey:KSearchKeyHeadline] isEqualToString:@"noresults"] &&
[[searchURL objectForKey:kSearchKeyNewsText] isEqualToString:@"noresults"] &&
[[searchURL objectForKey:kSearchKeyIssuerText] isEqualToString:@"noresults"]) {
NSURLRequest *req;
req=[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:kSearchBarNoResult,text.text]]];
[[[featuredAsset viewControler] iWebview] loadRequest:req];
}
else if([searchURL objectForKey:KSearchKeyHeadline][email protected]"noresults" &&
[searchURL objectForKey:kSearchKeyNewsText][email protected]"noresults" &&
[searchURL objectForKey:kSearchKeyIssuerText][email protected]"noresults"){
NSURLRequest *req;
req=[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithString:kSearchBarHeadlinesURL]]];
[[[featuredAsset viewControler] iWebview] loadRequest:req];
}
else if([[searchURL objectForKey:kSearchKeyNewsText]isEqualToString:@"noresults"] &&
[searchURL objectForKey:kSearchKeyNewsText][email protected]"noresults" &&
[[searchURL objectForKey:kSearchKeyIssuerText]isEqualToString:@"noresults"]){
NSURLRequest *req;
req=[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithString:kSearchBarNewsTextURL]]];
[[[featuredAsset viewControler]iWebview]loadRequest:req];
}
的問題是,它調用這兩個else if
條件。我必須調用最後的條件。我知道符號&&
將檢查條件 - 當整個條件爲真時,它將返回true。我做錯了什麼?
好吧,它已被編輯.........結果。我如何比較!= @「noresults」 – applelover 2011-06-14 19:33:45
@applelover - ![... isEqualToString:@「noresults」]會評估相反的結果。 – csano 2011-06-14 19:47:38
@Yan .....和jOK ......多謝朋友。 – applelover 2011-06-14 19:50:37