【发布时间】:2010-07-05 00:11:07
【问题描述】:
大家好,这应该是一项简单的任务,但由于某种原因,我让它变得更难了……我正在尝试将一些文本从 XML 文件保存到 NSString。但是当我调试它时,字符串显示“超出范围”。
这是我的代码:
在我的 .h 文件中:
@interface RootViewController : UIViewController<MBProgressHUDDelegate> {
NSString *thePW;
}
还有我的 .m 文件:
NSString *thePW;
...
- (void)viewDidLoad {
...
if(e == nil){
NSString *response = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
thePW = response; // <-- this is where it has "Out of scope"
[response release];
}
}
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex != [alertView cancelButtonIndex])
{
if (thePW == @"0000")
{
NSLog(@"correct!");
}
}
}
【问题讨论】:
标签: iphone cocoa-touch xcode iphone-sdk-3.0