0

I create a class to call UIAlertview show on my screen. I write the UIAlert function in another class. Both these two classes are not my viewController class.

I use this UIAlert, which is a UITextfield inside, to store texts into a plist file.

here is the class to call UIAlert:

#import "Story.h"

@implementation Story

...
+ (void)stage1
{
    AlertClass *pointer = [AlertClass new];
    [pointer doAlert];
}

here is the class AlertClass.m file:

- (void)doAlert
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    [alert show];

}
//this makes crash!
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    self.storyFlow.text = [alertView textFieldAtIndex:0].text;
}

Before I add UIAlertViewDelegate in the .h and override the method "clickedButtonAtIndex", it works great. However, I need to store some data from the UITextfield inside the alert view. I get crash and don't know the message it responds as following.

Please help me to solve this problem. Thanks.

[crash pic] https://dl.dropbox.com/u/47381923/crash.tiff

4

1 回答 1

0

对从警报视图返回的文本执行 NSLog 以查看是崩溃还是随后的“self.storyFlow.text =”导致它。也许 self.storyFlow 尚未创建(使用 alloc/init)

于 2012-09-15T09:26:03.753 回答