0
我已經搜索並嘗試了很多,但在我的應用程序(它使用的是iOS 5 SDK)中的NSURLConnection的委託方法被調用只有當我初始化,並開始在viewDidLoad方法或任何按鈕的點擊事件的連接。NSURLConnection的代表不工作
但我想我的解析JSON文件後調用它。爲JSON中的每條記錄創建一個新的連接。
誰能告訴我發生了什麼?東西在IOS SDK 5
這裏改變的是我的代碼:
-(void)getData:(NSString*)URL{
NSURLRequest *urlRequest = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:URL]];
shortURL = [NSString stringWithString:URL];
connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
//NSAssert(connection!=nil, @"no connection", nil);
[connection start];
}
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response
{
// application specific stuff
}
該功能的getData是寫在一個類繼承來自NSObject。它被稱爲
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
UITableView的方法。
請幫我這個。
發佈您的代碼... – esqew 2012-01-27 16:02:23
最後委託方法在iOS 5中讀depricated在文檔 – 2012-01-27 16:09:11
請在這裏提供的代碼塊,因此,實際的問題可以鑑定。 – iCreative 2012-01-27 16:22:30