开发者

UIAlertView title set sending "SIGABRT"

开发者 https://www.devze.com 2023-03-26 15:29 出处:网络
I\'m new to Cocoa Touch and I\'m just messing around trying to get a feel for the language and framework. So I\'m just trying to create a simple app that takes text from a UITextField and just shows i

I'm new to Cocoa Touch and I'm just messing around trying to get a feel for the language and framework. So I'm just trying to create a simple app that takes text from a UITextField and just shows it in a UIAlertView here is the action method:

开发者_JS百科
- (IBAction)showNotifAction:(id)sender {
    putVal = _TextToDisplay.text;
    _alertOne.title = @"Message";
    _alertOne.message = putVal;
    [_alertOne show];
}

For some reason it breaks on line 3 with a SIGART. Is there something I'm doing wrong? Oh, BTW, here is my AppDelegate implementation:

@interface LearnAppDelegate : NSObject <UIApplicationDelegate> {
    UITextField *_TextToDisplay;
    UIButton *_ShowNotif;    
    UIAlertView *_alertOne;
    NSString *putVal;
}


You need to define your UIAlertVIew. Pointer that you are trying to use points to nothing or to garbaged memory.

Try something like the following code:

    UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:"My title" 
message:putVal
delegate:nil 
cancelButtonTitle:@"OK" 
otherButtonTitles:nil] autorelease];
    [alert show];
0

精彩评论

暂无评论...
验证码 换一张
取 消