Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to call under viewdid load data when button click event action is done
    text
    copied!<p>I am developing Viewbased application.I have method look like this.-(IBAction)switchPage:(id)sender this method is button click event action. Now when we click on button it should load under view did load data but it is not loading can any one help regarding this</p> <pre><code>-(IBAction)switchPage:(id)sender { if(self.viewTwoController == nil) { ViewTwoController *viewTwo = [[ViewTwoController alloc] initWithNibName:@"View2" bundle:[NSBundle mainBundle]]; self.viewTwoController = viewTwo; [viewTwo release]; } [self.navigationController pushViewController:self.viewTwoController animated:YES]; [connection release]; } //in viw did load i have this code - (void)viewDidLoad { [super viewDidLoad]; responseData = [[NSMutableData data] retain]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://108.16.210.28/Account/LogOn"]]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { // label.text = [NSString stringWithFormat:@"Connection failed: %@", [error description]]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString *post =[[NSString alloc] initWithFormat:@"usernameField=%@&amp;passwordField=%@",usernameField.text,passwordField.text]; NSURL *url=[NSURL URLWithString:@"https://108.16.210.28/SSLLogin/Account/LogOn"]; NSLog(post); NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:url]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:postData]; /* when we user https, we need to allow any HTTPS cerificates, so add the one line code,to tell teh NSURLRequest to accept any https certificate, i'm not sure about the security aspects */ [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]]; NSError *error; NSURLResponse *response; NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error]; NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding]; NSLog(@"%@",data); } </code></pre> <p>enter code here</p>
 

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