私はiOS開発に不慣れなので、これが悪い質問である場合はお詫び申し上げます。これが私の問題です。クラス変数NSStringを宣言しました。文字列には、textViewから文字列値が割り当てられていますが、他のメソッドから文字列にアクセスしようとすると、アプリがクラッシュします。コードは次のとおりです。
インターフェイス:(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。