Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication Crashes. :(
    primarykey
    data
    text
    <p>I'm creating an app with login window. The application builds successfully but as soon as I touch the login button, the application crashes. :(</p> <p>I've pasted the .m file below.</p> <p>Where am I making the mistake? :(</p> <p>Thanks in Advance:)</p> <pre><code>#import "AuthViewController.h" @implementation AuthViewController @synthesize userName; @synthesize password; @synthesize loginbutton; @synthesize indicator; - (IBAction) loginButton: (id) sender { indicator.hidden = NO; [indicator startAnimating]; loginbutton.enabled = NO; // Create the username and password string. // username and password are the username and password to login with NSString *postString = [[NSString alloc] initWithFormat:@"username=%@&amp;password=%@",userName, password]; // Package the string in an NSData object NSData *requestData = [NSData dataWithBytes: [postString UTF8String] length: [postString length]]; // Create the URL request NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"http://localhost/dologin.php"]]; // create the URL request [request setHTTPMethod: @"POST"]; // you're sending POST data [request setHTTPBody: requestData]; // apply the post data to be sent // Call the URL NSURLResponse *response; // holds the response from the server NSError *error; // holds any errors NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse:&amp;response error:&amp;error]; // call the URL /* If the response from the server is a web page, dataReturned will hold the string of the HTML returned. */ NSString *dataReturned = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding]; alertWithOkButton = [[UIAlertView alloc] initWithTitle:@"Status..." message:@"%@",dataReturned cancelButtonTitle:@"Okay", nil]; [alertWithOkButton show]; [alertWithOkButton release]; } -(IBAction)dismissKeyboard: (id)sender { [sender resignFirstResponder]; } /* // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { // Custom initialization } return self; } */ /* // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } */ /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end </code></pre> <p>The header/.h File:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface AuthViewController : UIViewController { IBOutlet UITextField *userName; IBOutlet UITextField *password; IBOutlet UIButton *loginbutton; IBOutlet UIActivityIndicatorView *indicator; UIAlertView *alertWithOkButton; UIAlertView *alertWithYesNoButtons; } @property (nonatomic, retain) UITextField *userName; @property (nonatomic, retain) UITextField *password; @property (nonatomic, retain) UIButton *loginbutton; @property (nonatomic, retain) UIActivityIndicatorView *indicator; - (IBAction)dismissKeyboard: (id)sender; - (IBAction) loginButton: (id) sender; @end </code></pre>
    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.
    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