* result設置爲返回0或1的布爾值。如果結果返回值1,我想要做的事是讓它記錄下面的語句。將指針與if語句中的整數進行比較
我的日誌顯示它已成功記錄1的結果,但它不會記錄第2條語句「所有設置,讓我們將您發送到MatchCenter」。我不確定第二個if語句是否不在正確的位置,或者語法不正確。任何幫助表示讚賞。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if (sender != self.nextButton) return;
if (self.itemSearch.text.length > 0) {
[PFCloud callFunctionInBackground:@"eBayCategorySearch"
withParameters:@{@"item": self.itemSearch.text}
block:^(NSString *result, NSError *error) {
if (!error) {
NSLog(@"The result is '%@'", result);
if ((int)result == 1) {
NSLog(@"All set, let's send you to MatchCenter");
}
}
}];
}
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
將'result'投射到'int'就是將指針(內存地址)投射到'int'。這並不是接近將文本值轉換爲「int」的地方。 – rmaddy