【发布时间】:2011-10-25 04:04:45
【问题描述】:
请问,为什么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]? -
我尝试比较 UIText 归档和我的 globalpassord 但不起作用
-
编辑您的问题并添加一些关于出现问题的信息 - 是否崩溃?
-
在您的示例中,没有两个打印“pol”的 NSLog() 调用。添加下面我的答案中的行,这将显示任何空白差异。
-
globalpassword 是如何创建的?想要确保它的保留计数 > 0。
标签: iphone objective-c ipad nsstring