1
如果这是一个糟糕的问题,我很抱歉,因为我是iOS开发新手。所以这里是我的问题:我声明了一个类变量NSString,该字符串从textView中分配一个字符串值,但是当我尝试从其他方法访问字符串时,该应用程序崩溃。下面的代码:访问方法之间的NSString导致应用程序崩溃
接口:(ClassName.h)
@interface ClassName: UIViewController <UITextViewDelegate>{}
@property (nonatomic, assign)NSString *strSomeText;
@end
实施:(ClassName.m)
@implementation
@synthesize strSomeText;
- (void)textViewDidChange:(UITextView *)textView{
strSomeText = textView.text;
NSLog(@"%@", strSomeText); //This line works just fine
}
- (void)textViewDidEndEditing:(UITextView *)textView{
NSLog(@"%@", strSomeText); //this line causes the app to crash
}
@end
感谢您的帮助! Loc。
非常感谢杰西。有用! – user945711 2012-08-06 15:11:15