請問,爲什麼不isEqualToString
工作?比較NSString使用isEqualToString
- (void)viewDidLoad {
[super viewDidLoad];
extern NSString* globalpassword;
if ([passwo.text isEqualToString: globalpassword]) {
res = [[XMLTestViewController alloc] initWithNibName:@"XMLTestViewController" bundle:nil];
res.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.view addSubview:res.view];
} else {
NSLog(@"faux");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"chikos"
message:@"Wrong Password" delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
}
the result is
2011-08-11 17:56:36.543 XMLTest[6389:207] pol
2011-08-11 17:56:36.544 XMLTest[6389:207] pol
2011-08-11 17:56:36.544 XMLTest[6389:207] faux
你爲什麼用'stringWithString'而不是''[passwo.text isEqualToString:globalpassword]''來煩惱? – deanWombourne
我嘗試比較UIText字段和我的globalpassord但不工作 –
編輯您的問題並添加一些有關錯誤的信息 - 崩潰了嗎? – deanWombourne