NSThreadを使用しているときにコンソールに次のエラーメッセージが表示される "メインスレッドまたはウェブスレッド以外のスレッドからウェブロックを取得しようとしました。これはセカンダリスレッドからUIKitを呼び出した結果発生します。 ..」スレッドを使用するときにエラーを解決する方法は?
私はここに私のサンプルコードここ
- (void)viewDidLoad {
appDeleg = (NewAshley_MedisonAppDelegate *)[[UIApplication sharedApplication] delegate];
[[self tblView1] setRowHeight:80.0];
[super viewDidLoad];
self.title = @"Under Ground";
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[NSThread detachNewThreadSelector:@selector(CallParser) toTarget:self withObject:nil];
}
-(void)CallParser {
Parsing *parsing = [[Parsing alloc] init];
[parsing DownloadAndParseUnderground];
[parsing release];
[self Update_View];
//[myIndicator stopAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
提出持っている "DownloadAndParseUndergroundは、" RSSフィードからデータをdownloding方法と
-(void) Update_View{
[self.tblView1 reloadData];
}
WHですエンUpdate_View方法はにtableViewは、あなたがメソッドの構文解析では、スレッドを必要とする理由を説明し、適切なデータをリロードし、cellForRowAtIndexPathでエラーを作成し、カスタムセル
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
CustomTableviewCell *cell = (CustomTableviewCell *) [tblView1 dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"customCell"
owner:self
options:nil];
cell = objCustCell;
objCustCell = nil;
}
あなたの非同期ロードを「PerformSelectorOnMainThread」にあなたのコードは、(下記のコメント)2.Change一つだけのparam
であなたのViewControllerをロードするためのメソッドを追加し、なぜですか? – BoltClock
答えを読んでいるのは、どちらも間違っているからです(または、解読不可能なものです。 – bbum