Just want to confirm if this request is 100% secure connection - iphone

I am writing an iPhone App and I need to securely send an XML request and receive it ALL securely. I think I did it right I just want some confirmation that the below code is all secure.
NSURL *url = [NSURL URLWithString: #"https://secure.site.com/request"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:#"%d", [xml length]];
[req addValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[req addValue:msgLength forHTTPHeaderField:#"Content-Length"];
[req setHTTPMethod:#"POST"];
[req setHTTPBody: [xml dataUsingEncoding:NSUTF8StringEncoding]];
conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn)
webData = [[NSMutableData data] retain];
and in the connectionDidFinishLoading..
- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *gotXml = [[NSString alloc]
initWithBytes: [webData mutableBytes]
length:[webData length]
encoding:NSUTF8StringEncoding];

Yes, so long as the URL has https:// in it, the request will be sent securely.

Related

How to pass parameter in php webservice?

I am working in an app in which i need to pass the json object in that parameter of the request string, now I am stuck here and have no idea how to do this.
SBJSON *json = [SBJSON new];
json.humanReadable = YES;
responseData = [NSMutableData data] ;
NSString *service = #"http://localhost.abc.com/index.php?p=api/user/register";
NSString *requestString = [NSString stringWithFormat:#"{\"Name\":\"%#\",\"Email\":\"%#\",\"Password\":\"%#\",\"PasswordMatch\":\"%#\",\"TermsOfUSe\":\"1\"}",txtusername.text,txtemail.text,txtpassword.text,txtretypepassword.text];
NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];
NSString *urlLoc=#"";
urlLoc = [urlLoc stringByAppendingString:service];
NSLog(#"URL:- %#",urlLoc);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:
[NSURL URLWithString: urlLoc]];
NSString *postLength = [NSString stringWithFormat:#"%d", [requestData length]];
[request setHTTPMethod: #"POST"];
[request setValue:postLength forHTTPHeaderField:#"Content-Length"];
[request setValue:#"application/json" forHTTPHeaderField:#"Content-Type"];
[request setHTTPBody:requestData];
NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self];
NSLog(#"%#",request);
SBJSON *json = [SBJSON new];
json.humanReadable = YES;
responseData = [NSMutableData data] ;
NSString *service = #"http://localhost.abc.com/index.php?p=api/user/register";
NSString *requestString = [NSString stringWithFormat:#"{\"Name\":\"%#\",\"Email\":\"%#\",\"Password\":\"%#\",\"PasswordMatch\":\"%#\",\"TermsOfUSe\":\"1\"}",txtusername.text,txtemail.text,txtpassword.text,txtretypepassword.text];
NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];
NSString *urlLoc=#"";
urlLoc = [urlLoc stringByAppendingString:service];
NSLog(#"URL:- %#",urlLoc);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:
[NSURL URLWithString: urlLoc]];
NSString *postLength = [NSString stringWithFormat:#"%d", [requestData length]];
[request setHTTPMethod: #"POST"];
[request setValue:postLength forHTTPHeaderField:#"Content-Length"];
[request setValue:#"application/json" forHTTPHeaderField:#"Content-Type"];
[request setHTTPBody:requestData];
NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self];
NSLog(#"%#",request);
Delegate method of Connection
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[responseData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
//**check here for responseData & also data**
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
NSLog([NSString stringWithFormat:#"Connection failed: %#", [error description]]);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
//do something with the json that comes back ... (the fun part)
}
/ /// / ///////// EDITED Answer /////////////////////
GET Method: In this method you can append the request data behind the web- service.As you doing now by line [request setHTTPMethod: #"POST"];.
POST Method: In this method, you can't append the requested data. But pass the dictionary as a parameter. Like below:
NSArray *objects = [NSArray arrayWithObjects:[[NSUserDefaults standardUserDefaults]valueForKey:#"StoreNickName"],
[[UIDevice currentDevice] uniqueIdentifier], [dict objectForKey:#"user_question"], nil];
NSArray *keys = [NSArray arrayWithObjects:#"nick_name", #"UDID", #"user_question", nil];
NSDictionary *questionDict = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
NSDictionary *jsonDict = [NSDictionary dictionaryWithObject:questionDict forKey:#"question"];
NSString *jsonRequest = [jsonDict JSONRepresentation];
NSLog(#"jsonRequest is %#", jsonRequest);
NSURL *url = [NSURL URLWithString:#"https://xxxxxxx.com/questions"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSData *requestData = [NSData dataWithBytes:[jsonRequest UTF8String] length:[jsonRequest length]];
[request setHTTPMethod:#"POST"];
[request setValue:#"application/json" forHTTPHeaderField:#"Accept"];
[request setValue:#"application/json" forHTTPHeaderField:#"Content-Type"];
[request setValue:[NSString stringWithFormat:#"%d", [requestData length]] forHTTPHeaderField:#"Content-Length"];
[request setHTTPBody: requestData];
NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:request delegate:self];

posting data to server from iphone app

I am posting data to server from iphone app but it gives exception while reading post line code about "excess bad access".Same code I use for sending four variables data then it is working fine if i add more variables in post it gives an error.
NSString*category=titleCategory;
NSString*sub_Category=titleSubCategory;
NSString*content_Type=#"Audio";
content_Title=TitleTextField.text;
NSString*content_Title=content_Title;
NSString*publisher=#"Celeritas";
content_Description=descriptionTextField.text;
NSString*content_Description=content_Description;
NSString*content_ID=#"10";
NSString*content_Source=#"http://www.celeritas-solutions.com/pah_brd_v1/productivo/productivo/pro/ali.wav";
NSString *post =[[NSString alloc] initWithFormat:#"category=%#&sub_Category=%#&content_Type=%#&content_Title=%#&publisher=%#&content_Description=%#&content_ID=%#&content_Source=%#",category,sub_Category,content_Type,content_Title,publisher,content_Description,content_ID,content_Source];
NSURL *url=[NSURL URLWithString:#"http://www.celeritas-solutions.com/pah_brd_v1/productivo/addData.php"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
[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];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(#"%#",data);
Below is the line where it breaks the code
NSString *post =[[NSString alloc] initWithFormat:#"category=%#&sub_Category=%#&content_Type=%#&content_Title=%#&publisher=%#&content_Description=%#&content_ID=%#&content_Source=%#",category,sub_Category,content_Type,content_Title,publisher,content_Description,content_ID,content_Source];
Try this
NSString *args = #"category=%#&sub_Category=%#&content_Type=%#&content_Title=%#&publisher=%#&content_Description=%#&content_ID=%#&content_Source=%#";
NSString *values=[NSString stringWithFormat:args,category,sub_Category,content_Type,content_Title,publisher,content_Description,content_ID,content_Source];
NSData *postData = [values dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSString *path = [[NSString alloc] initWithFormat:#"%s",your urlpath];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:path]];
[request setHTTPMethod:#"POST"];
[request setValue:postLength forHTTPHeaderField:#"Content-Length"];
[request setHTTPBody:[values dataUsingEncoding:NSISOLatin1StringEncoding]];
[request setHTTPBody:postData];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&err];
NSString *returnString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[NSURLConnection connectionWithRequest:request delegate:self];
//NSLog(#"String==> %#",returnString);
Hope this helps...
Good luck !!
Following code a help a lot while i test into the project as well as
In .h File
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController{
NSURLConnection *connection;
NSMutableData *responseData;
}
#end
In.m File
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString*category=#"Cat1";
NSString*sub_Category=#"Title";
NSString*content_Type=#"Audio";
NSString* content_Title=#"Test";
NSString*publisher=#"Celeritas";
NSString*content_Description=#"Content Description";
NSString*content_ID=#"10";
NSString*content_Source=#"http://www.celeritas-solutions.com/pah_brd_v1/productivo/productivo/pro/ali.wav";
NSString*post = [NSString stringWithFormat:#"category=%#&sub_Category=%#&content_Type=%#&content_Title=%#&publisher=%#&content_Description=%#&content_ID=%#&content_Source=%#",category,sub_Category,content_Type,content_Title,publisher,content_Description,content_ID,content_Source];
NSURL *url=[NSURL URLWithString:#"http://www.celeritas-solutions.com/pah_brd_v1/productivo/addData.php"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
[request setHTTPMethod:#"POST"];
[request setValue:postLength forHTTPHeaderField:#"Content-Length"];
[request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[request setHTTPBody:postData];
connection=[NSURLConnection connectionWithRequest:request delegate:self];
if(connection){
responseData=[NSMutableData data];
}
}
#pragma NSUrlConnection Delegate Methods
-(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 {
// [delegate APIResponseArrived:NULL];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *responseString =[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
// [delegate APIResponseArrived:responseString ];
NSLog(#"%#",responseString);
}
This code solve your problem.
I got the solution of the question actually there was variable assignment issue for their invailded address that is why it was giving access bad error i assigned values directly then it worked for me fine like
NSString*category=#"Category";
NSString*sub_Category=#"Working";
NSString*content_Type=#"Audio";
NSString*content_Title=#"Content Title";
NSString*publisher=#"Celeritas";
NSString*content_Description=#"ContentDescription";
NSString*content_ID=#"10";
NSString*content_Source=#"http://www.celeritas-solutions.com/pah_brd_v1/productivo/productivo/pro/ali.wav";
NSString *post =[[NSString alloc] init];
post = [NSString stringWithFormat:#"category=%#&sub_Category=%#&content_Type=%#&content_Title=%#&publisher=%#&content_Description=%#&content_ID=%#&content_Source=%#",category,sub_Category,content_Type,content_Title,publisher,content_Description,content_ID,content_Source];
NSURL *url=[NSURL URLWithString:#"http://www.celeritas-solutions.com/pah_brd_v1/productivo/addData.php"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
[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];

Login credential issue using NSURL Methods

I have an webservices url which appends with password. When I run the application by giving correct password, the application is running and at the same time when I run the app with wrong credentials. the app is running, I didn't have an idea to get rid out of the issue. My code is here:
NSString *post =[[NSString alloc] initWithFormat:#"password=%#",[password text]];
NSLog(#"PostData: %#",post);
NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:#"http://myexample.com/Accountservice/Secure/ValidateAccess?password=abcd&type=1"]];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:#"POST"];
[request setValue:postLength forHTTPHeaderField:#"Content-Length"];
[request setValue:#"application/json" forHTTPHeaderField:#"Accept"];
[request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[request setHTTPBody:postData];
NSURLRequest *request1 = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:post] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request1 delegate:self startImmediately:YES];
if(!connection){
NSLog(#"connection failed");
}
else{
NSLog(#"connection succeeded");
}
If I gave 'abcd' as password connection is successfully is displaying. If I gave wrong password connection successfully is displaying. How can I solve the issue? If I gave wrong password need to display an alert.
This control structure here is the problem:
if(!connection){
NSLog(#"connection failed");
}
else {
NSLog(#"connection succeeded");
}
This doesn't check for a bad connection, this checks whether or not the connection object is equal to 0 (nil). Obviously, having initialized it on the line above, the else statement will always log, giving you the false impression that your connection had succeeded. You should become the connection's delegate, and respond to the appropriate delegate methods instead.
The issue may be with the url you are using
Fire the url in the browser and see what it returnes
try add the url params with single quotes accesscode='abcd'
It is not a good practice to pass the credentials via this way.
You could use POST method with some valid encryption to prevent the security issues that can occur
SOLUTION
Try this
NSString *urlString=#"http://myexample.com/Accountservice/Secure/ValidateAccess?";
self.responseData = [NSMutableData data];
NSString *post =[NSString stringWithFormat:#"username=%#&password=%#",userNameTextField.text,passwordTextField.text];
NSData *postData=[post dataUsingEncoding:NSUTF8StringEncoding];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:#"POST"];
[request setValue:postLength forHTTPHeaderField:#"Content-Length"];
[request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *connection0= [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection0 start];

error while making URL request iPhone

I asked a question and followed following way(suggested by Jaybit):
Pass username and password in URL for authentication
Now, I'm getting this error(stack track):
2013-02-12 11:56:11.734 Calendar[4074:c07] didReceiveData
2013-02-12 11:56:19.519 Calendar[4074:c07] receivedString:<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read()
at System.Xml.XmlReader.MoveToContent()
at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent()
at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()
at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
--- End of inner exception stack trace ---</soap:Text></soap:Reason><soap:Detail /> </soap:Fault></soap:Body></soap:Envelope>
(lldb)
Here is my code:
- (IBAction)btnLoginClick:(id)sender
{
//Call Calendar View
if(self.viewController == nil) {
CalendarViewController *detailView = [[CalendarViewController alloc] initWithNibName:#"CalendarViewController" bundle:nil];
self.viewController = detailView;
}
NSString *userName = [NSString stringWithFormat:#"parameterUser=%#",txtUserName];
NSString *passWord = [NSString stringWithFormat:#"parameterPass=%#",txtPassword];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"http://URL/service1.asmx?"]];
NSString *postString = [NSString stringWithFormat:#"username=%#&password=%#",userName, passWord];
NSLog(#"%#",userName);
NSLog(#"%#",passWord);
NSData *postData = [NSData dataWithBytes: [postString UTF8String] length: [postString length]];
//URL Requst Object
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:600];
[request setHTTPMethod:#"POST"];
[request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[request setHTTPBody: postData];
appConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[self.appConnection start];
//tryed with Async...
/* NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
NSString *receivedString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(#"receivedString:%#",receivedString);
}];*/
[self.navigationController pushViewController:self.viewController animated:YES];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
tempdata = data;
NSLog(#"didReceiveData");
if (!self.receivedData){
self.receivedData = [NSMutableData data];
}
[self.receivedData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(#"connectionDidFinishLoading");
NSString *receivedString = [[NSString alloc] initWithData:tempdata encoding:NSUTF8StringEncoding];
NSLog(#"receivedString:%#",receivedString);
}
please help.thank.
I've worked with requesting a soap URL before, the following code worked for me:
NSString *soapMessage = [NSString stringWithFormat:
#"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n"
"<YourServiceName xmlns=\"http://tempuri.org/\">\n"
"<username>%#</username>\n"
"<passowrd>%#</passowrd>\n"
"</YourServiceName>\n"
"</soap:Body>\n"
"</soap:Envelope>\n", userName, passWord
];
NSURL *url = [NSURL URLWithString:#"http://URL/service1.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:#"%d", [soapMessage length]];
[theRequest addValue: #"text/xml; charset=utf-8" forHTTPHeaderField:#"Content-Type"];
[theRequest addValue: [NSString stringWithFormat:#"http://tempuri.org/%#",service] forHTTPHeaderField:#"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:#"Content-Length"];
[theRequest setHTTPMethod:#"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[theRequest setTimeoutInterval:10];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( theConnection )
{
responseData = [[NSMutableData data] retain];
}
else
{
NSLog(#"theConnection is NULL");
}

XML parsing is not working as expected in Objective-C

I am new to iPhone programming, and this is the first time parsing XML file. I have added the url and also hardcoded the XML file into the string, however I am not getting the correct response from the server.
Here is my code:
NSString *post = #"<?xml version=\"1.0\"encoding=\"UTF-8\"?<request><call>GetNewChapters</call><udid>1000000000000000000000000000000000000000</udid><book_id>1</book_id><updatetoken>B20100125054802</updatetoken></request>";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSURL *url=[NSURL URLWithString:#"https://www.paisible.com/babelle_api"];
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];
NSString *myStr = [[NSString alloc] initWithData:postData encoding:NSUTF8StringEncoding];
NSLog(#"String Value :%#",myStr);
NSLog(#"theRequest: %#", request);
NSURL *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(theConnection)
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(#"theConnection is NULL");
}
Where as webdata is NSMutable data. Please let me know what errors I have made in my parsing code.
Try to replace
NSURL *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
with the following:
NSURLResponse *resp;
NSError *error;
NSMutableData *webData = [NSURLConnection sendSynchronousRequest:request returningResponse:&resp error:&error];
Than, check what "webData" contains.