데이터를 다시로드하거나 새로 고치려면 UITableViewController를 가져 오는 데 문제가 있습니다.UITableViewController가 데이터를 다시로드하지 않습니다. - ASIHTTPRequest
ASIHTTPRequest를 사용하여 URL을 호출하고 일부 문자열 데이터를 가져 오는 메소드가 있습니다. 이 데이터를 테이블의 셀에 넣으려고하지만 [self.tableview reloadData]가 작동하지 않습니다.
은 내가 ASIHTTPRequest는 별도의 스레드에서의 작업을 완료 할 것으로 생각하고 있었다, 그래서 나는 시도 :[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
하는 것도 아무것도하지 않았다한다.
어떻게 데이터를 다시로드 할 수 있습니까? 나는 얼마 동안이 일에 매달 렸습니다.
코드 : MainViewController.h
#import <UIKit/UIKit.h>
@class ProductClass;
@interface MainViewController : UITableViewController {
ProductClass *item;
}
@property (nonatomic, retain) ProductClass *item;
@end
MainViewController.m
#import "MainViewController.h"
#import "ASIHTTPRequest.h"
#import "ProductClass.h"
@implementation MainViewController
@synthesize item;
- (void) viewDidLoad {
self.title = @"TableView Test";
self.tableView.allowsSelection = NO;
self.item = [[ProductClass alloc] init];
[self callURL];
}
-(void)callURL {
NSURL *url = [NSURL URLWithString:@"http://urlgoeshere.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request {
//Grab the response
NSString *responseString = [request responseString];
//Put the result into the ProductClass item
item.titleOfProduct = responseString;
//This line shows that self.tableview does NOT have an address of 0x0
NSLog(@"%@\n", self.tableView);
//Problem line!!!!!!
[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
//The below lines also do nothing!!!!
//[self.tableView reloadData];
//[[self tableView] reloadData];
}
누구나 어떤 아이디어가 ??? 나는 총 손실에 처해있다.
건배, 브렛