2014-03-04 36 views
-1

搜索後谷歌和堆棧溢出沒有成功找出我的問題...在iOS中設置新的視圖

從第一視圖(登錄視圖)從sqlite3訪問數據。爲有效用戶的應用程序有一個新的觀點,以下載數據和
我被NSURLConnection的發送請求,我不知道哪裏是剛開

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

的問題,這是到目前爲止我的代碼.. 在我.h文件中

@property(nonatomic ,retain) NSURLConnection *URLConnection; 

IM的.mi正常合成,並用它作爲

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]; 
    } 
} 

一件事想我,當我我打電話這對同樣的觀點,這只是完美的,但現在給我上面的錯誤... 需要在這個問題上... :(

對不起你的幫助,但我編輯我的問題其實 這不是NSURLConnection的誤差在所有,因爲我已經在這個視圖上設置了一個新的按鈕,並且按下了按鈕,我打電話給一個新的視圖...這裏是我面對的同樣的問題......。 這是我的呼籲新的視圖代碼

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

,並已包括在該視圖的.h文件中 Mainview.h文件現在請帶我找出問題...

+0

你在哪裏設置它的代表? –

+0

@HimanshuJoshi沒有得到你的觀點你在問什麼......其實我是新的iOS –

+0

你是否在目標類中設置了NSURLConnectionDelegate? ** YourClass ** –

回答

1

要添加的視圖控制器作爲子視圖,這是錯誤的..相反,你必須打開新的ViewController。

MainView *main = [[MainView alloc] initWithNibName:@"MainView" bundle:nil]; 
[self presentViewController:main animated:YES completion:nil]; 
+0

移動到下一個視圖... NSLog的新視圖顯示在控制檯中,但再次崩潰與lldv錯誤... :( –

+0

你能提供你的代碼在http://pastie.org/? –

+0

是的,它工作...其實我正在使用我的代碼這個子視圖代碼的另一部分...改變了它,現在它的工作完美...非常感謝和愛你 –

相關問題