Note that there are some explanatory texts on larger screens.

plurals
  1. POUIAlertView fails to show and results in “EXC_BAD_ACCESS” error
    primarykey
    data
    text
    <p>A method is called when a return button on the keyboard is pressed. After calling another method which returns an integer a message is created based on that integer. The message is then passed into an UIAlterView and displayed to the user. The alert doesn't have any options (hence why I'm not calling a delegate), but simply notifies the user of what happened.</p> <p><strong>Edit:</strong> Below is the full method (previously displayed partial). When I comment out everything before the <code>UIAlertView</code> and substitute the string @"test" instead of passing message the Alert is shown successfully. Am I not handling memory correctly with my structure?</p> <pre><code>- (IBAction)joinButton { struct userInfo localUser; [emailAddress resignFirstResponder]; //convert textField text to char array in structure localUser.firstName = [self convertStringtoCharArray:firstName.text]; localUser.lastName = [self convertStringtoCharArray:lastName.text]; localUser.username = [self convertStringtoCharArray:username.text]; localUser.email = [self convertStringtoCharArray:emailAddress.text]; localUser.ipAddress = [self convertStringtoCharArray:localIPAddress.text]; localUser.latitude = currentLocation.coordinate.latitude; localUser.longitude = currentLocation.coordinate.longitude; //pass structure to be sent over socket int result = [myNetworkConnection registerWithServer:&amp;localUser]; NSString *message = nil; //process result of sending attempt if (result == 0) { //registration succesful message = [NSString stringWithString:@"Registration successful"]; } else if (result == 1) { //server unavailable message = [NSString stringWithString:@"Server unavailable. Please check your wi-fi settings and try again."]; } else if (result == 2) { //unable to establish connection message = [NSString stringWithString:@"Unable to communicate with server. Please check your wi-fi settings and try again."]; } else if (result == 3) { //username already in use message = [NSString stringWithString:@"Username in use. Try another username."]; } UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Registration" message:message delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; [alert release]; } </code></pre> <p>When I execute the code the iPhone greys out like it is about to display an alert but crashes. I get a <code>EXC_BAD_ACCESS</code> error in the console. Am I not releasing either the alert or the message correctly? Here is the console output:</p> <pre><code>Program received signal: “EXC_BAD_ACCESS”. (gdb) backtrace #0 0x30011944 in objc_msgSend () #1 0x3054803e in NSPopAutoreleasePool () #2 0x3054c808 in -[NSAutoreleasePool release] () #3 0x30936ac4 in _UIApplicationHandleEvent () #4 0x3204696c in PurpleEventCallback () #5 0x30254a76 in CFRunLoopRunSpecific () #6 0x3025416a in CFRunLoopRunInMode () #7 0x320452a4 in GSEventRunModal () #8 0x308f037c in -[UIApplication _run] () #9 0x308eea94 in UIApplicationMain () #10 0x000020bc in main (argc=1, argv=0x2ffff508) at /Users/reu2009/Documents/iPhone Development/Development/BuddyTracker/main.m:14 (gdb) frame 10 #10 0x000020bc in main (argc=1, argv=0x2ffff508) at /Users/reu2009/Documents/iPhone Development/Development/BuddyTracker/main.m:14 14 int retVal = UIApplicationMain(argc, argv, nil, nil); </code></pre> <p><strong>Edit:</strong> removed <code>[message release];</code> and assigned strings using <code>[NSString stringWithString];</code> based on answers.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload