Question

after searching on google and stack overflow don't succeed to figure out my problem…

from first view (login view) accessing data from sqlite3 . for valid users app has a new view to download data and
i am sending a Request by NSURLConnection, i don't know where is the problem just getting

lldv error ,, thread 1: EXC_BAD_ACCESS code = 1, address = 0.------ (different every time)

this is my code so far.. in my .h file

@property(nonatomic ,retain) NSURLConnection *URLConnection;

im .m i synthesize properly and using it as

message = @""; // SQL query in XML formate
URL = [NSURL URLWithString:@"http://www.xxxxxx.co.uk/xmlserver/xxxxx.php"];
Request = [NSMutableURLRequest requestWithURL:URL];
[Request setHTTPMethod:@"POST"];
[Request setValue:@"application/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[Request setHTTPBody:[message dataUsingEncoding:NSUTF8StringEncoding]];
NSError *Error = nil;
//NSLog(@"%@",message);
                                                  //here i am getting the error…. 
URLConnection = [[NSURLConnection alloc] initWithRequest:Request delegate:self];

if (URLConnection)              
{
    {
        NSData *XmlFile = [ NSURLConnection sendSynchronousRequest:Request returningResponse: nil error: nil ];
        ErrorParsing=NO;
        NSLog(@"Get data of XML...%ld",(long)QueryNumber);
        XmlParser = [[NSXMLParser alloc] initWithData: XmlFile];
        [XmlParser setDelegate:self];
        [XmlParser parse];
    }
}

One more thing wondering me that when i am calling this on the same view it was just perfect , but now giving me the above error… need your help on this issue… :(

sorry but i am editing my question actually this is not the NSURLConnection error at all, because i have set a new button on this view and on button pressed i am calling a new view … and here is the same issue i am facing …. this is my new view calling code

MainView *Main = [[MainView alloc] initWithNibName:@"MainView" bundle:nil];
[self.view addSubview:Main.view];

and already include Mainview.h file in this view's .h file now please lead me to figure out the issue…

Was it helpful?

Solution

You are adding the ViewController as a subView, which is wrong.. instead you have to open the new ViewController.

MainView *main = [[MainView alloc] initWithNibName:@"MainView" bundle:nil];
[self presentViewController:main animated:YES completion:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top