【发布时间】:2013-08-06 10:55:10
【问题描述】:
我有以下代码:
- (IBAction)topSecretFetchComplete:(ASIHTTPRequest *)theRequest{
strFinal = [theRequest responseString];
NSLog(@"Sattus Code : %@",[theRequest responseString]);
[self GoTo];
}
我正在使用ASIHttp进行登录。如果登录成功strFinal设置为successfully,如果不是设置为failed。
我的GoTo 方法是
-(void)GoTo{
NSString *failStr = @"failed";
NSString *successStr = @"successfully";
if (strFinal == successStr) {
//Navigate to other xib
}else
if (strFinal == failStr) {
UIAlertView *AlertFail = [[UIAlertView alloc] initWithTitle:@"LogIn Failed !" message:@"Wrong ID or Password" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[AlertFail show];
}
}
}
问题是除非strFinal失败,否则不会显示警报。
【问题讨论】:
-
上面的代码真的有效吗?正如您在代码中提到的字符串不匹配!
-
哇,5 分钟内重复问题的 8 个答案!!
-
将
GoTo方法名也重命名为 camelCase 符号!!