スレッドに問題があります。 スレッドがビジー状態のときに、2つの画面の間で数回セグをした後。スレッドはすべての行を実行しません..、メインスレッドに戻る必要があるときにブレークポイントは消えます。 誰か助けてくれますか?iOS - スレッドはメインスレッドに戻りません
ビューがアンロードされたときにスレッドを解放します。
おかげで、次のコード
- (void)fetchFeedDataIntoDocument
{
NSString * labelString = [NSString stringWithFormat:@"Feed Fetcher %@", self.pageTitle];
const char *label = [labelString UTF8String];
self.fetchF = dispatch_queue_create(label, NULL);
dispatch_async(self.fetchF, ^{
NSArray *feeds = [FeedFetcher getDataForJson:self.pageTitle downloadBy:@"up"];
NSDictionary *lastfeed;
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [appDelegate getManagedObjectContext];
if ([feeds count] > 0)
{
lastfeed = [feeds objectAtIndex:0];
[FeedFetcher setLastUpdateIdToCatgorie:self.pageTitle WithId:[lastfeed objectForKey:@"id"] AndPulishDate:[lastfeed objectForKey:@"publish_up"]];
}
for (NSDictionary *feedInfo in feeds) {
[Feed FeedWithInfo:feedInfo InManageObject:context];
}
NSError *error = nil;
[context save:&error];
if (error){
NSLog(@"Error save : %@", error);}
dispatch_async(dispatch_get_main_queue(), ^{
[self setupFetchedResultsController];
[self.tableView reloadData];
[self downloadImagesForFeeds:feeds];
});
});
私はこのエラーが発生しました:)、キャッチされていない例外' NSInvalidArgumentException 'のためにアプリケーションを終了しています。理由:'親NSManagedObjectContextはNSPrivateQueueConcurrencyTypeまたはNSMainQueueConcurrencyTypeのいずれかを使用する必要があります。 ' –
OK、 "Xcodeテンプレートで作成されたMOC。 –
ありがとう、ありがとう、私はそれが解決したと思う:D、それは今うまく動いている –