我想創建一個nsobject,它將擁有我的所有方法,這些方法將用於與我的php腳本交談並從我的數據庫獲取數據。nsObject使用ASIHTTPRequests
我想使用ASIHTTPRequest包裝爲我做這件事,但我不知道如何構造這個nsobject,因爲會有幾個方法調用不同的PHP腳本(或在不同的功能相同的PHP)。
我在哪裏得到升技是在考慮從視圖中調用nsobject方法的地方,我想從數據庫中顯示數據,因爲我不知道如何使用 - (void)獲取數據到視圖)requestFinished:(ASIHTTPRequest *)請求{方法。
例如將NSObject的是這樣
//...
-(IBAction) method1
{
NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
}
-(IBAction) method2
{
NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
}
-(IBAction) method3
{
NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
}
//Then catch each method request with one
- (void)requestFinished:(ASIHTTPRequest *)request{ //etc
//and use one failed request
- (void)requestFailed:(ASIHTTPRequest *)request{ //etc
或者你把你要顯示的信息的視圖裏面的requestFinished方法?
是的,這是有道理的。我對uitableviews的經驗有限,我正在越來越好,只是在什麼時候以及何處傳遞數據等等,這讓我ab ab不已。 –