how to request url to execute or connect to server ..
what i was using not working..
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@%@%@%@%@%@%@%@%@",[ConfigDB valueForKey:@"mailURL"], @"?ownerID=", [ConfigDB ownerID], @"&userid=",[ConfigDB userID],@"&pID=",pid,@"&emailAddress=",emailTxtField.text,[ConfigDB valueForKey:@"showEmailFlag"]]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:url];
That’s quite a
stringWithFormatmessage! The first thing to check is that you’re getting a URL that matches your expectations.Once you’ve got a URL request object—and consider using a regular
NSURLRequest, it should be faster and it doesn’t look like you’re intending to reuse this object:Then you need to actually make the request. There are two approaches here. You’ll use
NSURLDownloadif you’re looking to save the request to file. It looks like you’re looking to make aGETrequest to an email server of some sort, so you probably want the other approach:NSURLConnection.NSURLConnectionis mostly intended for asynchronous requests. You provide a delegate with some methods and your NSURLConnection will use those methods to let you know when the communication is done; whether there were errors; etc.Add a property to your view controller class for the connection, and an
NSMutableDataproperty as well. You will start your connection with (assuming that your current class is also your delegate):In your code somewhere—probably your current view controller—you’ll need to implement those methods: