EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000a1657e0b崩溃

时间:2016-11-25 06:41:00

标签: ios objective-c

我在将数据上传到服务器时遇到的这次崩溃

我首先将所有数据存储到CoreData,而不是尝试在亚马逊服务器上传图像,而不是在调用网络服务之后

Crashed: com.apple.main-thread
        0  libobjc.A.dylib                0x244a7a86 objc_msgSend + 5
        1  CoreFoundation                 0x24bf3901 -[__NSCFNumber isEqual:] + 32
        2  CoreData                       0x267fc121 -[NSManagedObject changedValuesForCurrentEvent] + 328
        3  CoreData                       0x267fb739 -[NSFetchedResultsController(PrivateMethods) _preprocessUpdatedObjects:insertsInfo:deletesInfo:updatesInfo:sectionsWithDeletes:newSectionNames:treatAsRefreshes:]
+ 972
        4  CoreData                       0x268ee2c1 __77-[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:]_block_invoke + 1404
        5  CoreData                       0x267fae5b -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 122
        6  CoreFoundation                 0x24c8f295 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
        7  CoreFoundation                 0x24c8eca3 _CFXRegistrationPost + 398
        8  CoreFoundation                 0x24c8ea79 ___CFXNotificationPost_block_invoke + 40
        9  CoreFoundation                 0x24ce5ee3 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1334
        10 CoreFoundation                 0x24bee02b _CFXNotificationPost + 486
        11 Foundation                     0x254339c7 -[NSNotificationCenter postNotificationName:object:userInfo:] + 70
        12 CoreData                       0x267fadc3 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 78
        13 CoreData                       0x26866ef9 -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:]
+ 996
        14 CoreData                       0x267f93eb -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 2674
        15 CoreData                       0x267f1dfb _performRunLoopAction + 350
        16 CoreFoundation                 0x24c9f2b1 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
        17 CoreFoundation                 0x24c9d5a7 __CFRunLoopDoObservers + 282
        18 CoreFoundation                 0x24c9d9e5 __CFRunLoopRun + 972
        19 CoreFoundation                 0x24bec1c9 CFRunLoopRunSpecific + 516
        20 CoreFoundation                 0x24bebfbd CFRunLoopRunInMode + 108
        21 GraphicsServices               0x26208af9 GSEventRunModal + 160
        22 UIKit                          0x29324435 UIApplicationMain + 144
        23 eAudit                         0x188989 main (main.m:16)
        24 libdispatch.dylib              0x24898873 (Missing)

以下是我使用NSFetchResultController

的代码
- (NSFetchedResultsController *)fetchedResultsController {

    if (_fetchedResultsController != nil) {
        return _fetchedResultsController;
    }
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription
                                   entityForName:NSStringFromClass([UploadManager class]) inManagedObjectContext:[CoreDataManager sharedCoreData].managedObjectContext];

    [fetchRequest setEntity:entity];

    NSSortDescriptor *sort = [[NSSortDescriptor alloc]
                              initWithKey:@"submited_date" ascending:YES];
    [fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];

    [fetchRequest setFetchBatchSize:20];

    NSFetchedResultsController *theFetchedResultsController =
    [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                        managedObjectContext:[CoreDataManager sharedCoreData].managedObjectContext sectionNameKeyPath:nil
                                                   cacheName:nil];
    self.fetchedResultsController = theFetchedResultsController;
    _fetchedResultsController.delegate = self;

    return _fetchedResultsController;

}

- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
    // The fetch controller is about to start sending change notifications, so prepare the table view for updates.
    [self.tableViewUploadStatus beginUpdates];
}


- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {

    @try {
        UITableView *tableView = self.tableViewUploadStatus;

        switch(type) {

            case NSFetchedResultsChangeInsert:
                [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;

            case NSFetchedResultsChangeDelete:
                [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;

            case NSFetchedResultsChangeUpdate:
                [self configureCell:(UploadStatusTableViewCell *)[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
                break;

            case NSFetchedResultsChangeMove:
                [tableView deleteRowsAtIndexPaths:[NSArray
                                                   arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                [tableView insertRowsAtIndexPaths:[NSArray
                                                   arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;
        }
    } @catch (NSException *exception) {
        NSLog(@"Exception:- %@",exception.description);
    } @finally {

    }


}

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
    // The fetch controller has sent all current change notifications, so tell the table view to process all updates.
    [self.tableViewUploadStatus endUpdates];
}

0 个答案:

没有答案