获取与释放实例有关的崩溃

如何解决获取与释放实例有关的崩溃

| 我在dealloc的第
[selectedSession release];
行崩溃:
Default [NSCheapMutableString release]: message sent to deallocated instance
我不明白为什么不正常使用dealloc? 下面所有当前代码: LogViewController
    @implementation LogViewController

    @synthesize fetchedResultsController = __fetchedResultsController;
    @synthesize managedObjectContext;
    @synthesize logArray;
    @synthesize logTableView;
    @synthesize imageView;
    @synthesize session;
    @synthesize selectedSession;

    - (void)dealloc
    {
        [logArray release];
        [logTableView release];
        [session release];
        [__fetchedResultsController release];
        [managedObjectContext release];
        [imageView release];
        [selectedSession release];
        [super dealloc];
    }

    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
    }

    #pragma mark - View lifecycle

    - (void)viewDidLoad
    {
        self.logTableView.rowHeight = 47;
        [super viewDidLoad];
        self.navigationItem.title = @\"Log\";
        logTableView.backgroundColor = [UIColor clearColor];
        logTableView.separatorColor = [UIColor grayColor];
        self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:24/255.0 green:83/255.0 blue:170/255.0 alpha:1.0];
        self.logArray = [[NSArray alloc]initWithObjects:@\"Today\",@\"Previous\",@\"Past Week\",@\"Past Month\",@\"All Workouts\",nil];

        if (managedObjectContext == nil) 
        { 
            self.managedObjectContext = [(CurlAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; 
        }
    }

    - (void)viewDidUnload
    {
        self.logTableView = nil;
        self.fetchedResultsController = nil;
        self.imageView = nil;
        self.managedObjectContext = nil;
        [super viewDidUnload];
    }

    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    }

    - (void)viewWillDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
    }

    - (void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }

    #pragma mark - Table view data source


    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return [self.logArray count];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @\"Cell\";
        TDBadgedCell *cell = [[[TDBadgedCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
        [self configureCell:cell atIndexPath:indexPath];
        return cell;
    }

    - (void)configureCell:(TDBadgedCell *)cell atIndexPath:(NSIndexPath *)indexPath
    {
        cell.textLabel.textColor = [UIColor blackColor];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.textLabel.text = [logArray objectAtIndex:indexPath.row];
        cell.backgroundColor = [UIColor clearColor];
        cell.imageView.image = [UIImage imageNamed:@\"17-bar-chart.png\"];
        UIImageView *myImageView = nil;
        myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"silvercell5.png\"]];
        [cell setBackgroundView:myImageView]; 
        [myImageView release];

        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
        [dateFormatter setDateFormat:@\"MMM d,y\"]; 
        NSDate *date = nil;
        if (indexPath.row == 0)
        {
            date = [NSDate date]; 
            NSString *dateString = [dateFormatter stringFromDate:date]; 
            cell.badgeString = dateString;
        }
        else if (indexPath.row == 1)
        {
            if ([[self.fetchedResultsController fetchedObjects]count] > 1)
            {
                self.session = [[self.fetchedResultsController fetchedObjects]objectAtIndex:1];
                NSDate *date = self.session.timeStamp;
                NSString *dateString = [dateFormatter stringFromDate:date]; 
                cell.badgeString = dateString;
            }
            else
            {
                cell.badgeString = @\"None\";
            }
        }
        else if (indexPath.row > 1)
        {
            cell.badgeString = [NSString stringWithFormat:@\"%i\",[[self.fetchedResultsController fetchedObjects]count]];
        }
        cell.badgeColor = [UIColor colorWithRed:24/255.0 green:83/255.0 blue:170/255.0 alpha:1.0];
        [dateFormatter release]; 
    }

    #pragma mark - Table view delegate

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {    
        [tableView deselectRowAtIndexPath:indexPath animated:YES];

        if (indexPath.row == 0 || indexPath.row == 1)
        {
            SessionViewController *detailViewController = [[SessionViewController alloc] initWithNibName:@\"SessionViewController\" bundle:nil];
            detailViewController.title = [logArray objectAtIndex: indexPath.row];
            self.selectedSession = (Session *)[__fetchedResultsController objectAtIndexPath:indexPath];
            detailViewController.selectedSession = self.selectedSession;
            NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
            [dateFormatter setDateFormat:@\"MMM d,y\"]; 
            NSString *dateString = [dateFormatter stringFromDate:selectedSession.timeStamp]; 
            detailViewController.title = dateString;
            [self.navigationController pushViewController:detailViewController animated:YES];
            [detailViewController release];
            [dateFormatter release];
        }
        else
        {
            LogResultsViewController *detailViewController = [[LogResultsViewController alloc] initWithNibName:@\"LogResultsTableViewController\" bundle:nil];
            detailViewController.title = [logArray objectAtIndex: indexPath.row];
            [self.navigationController pushViewController:detailViewController animated:YES];
            [detailViewController release];   
        }
    }
#pragma mark - Fetched results controller

- (NSFetchedResultsController *)fetchedResultsController
{
    if (fetchedResultsController != nil)
    {
        return fetchedResultsController;
    }

    // Create the fetch request for the entity.
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    // Edit the entity name as appropriate.
    NSEntityDescription *entity = [NSEntityDescription entityForName:@\"Session\" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0] ;
    NSDate *today = [NSDate date]; 
    NSDate *thisWeek  = [today dateByAddingTimeInterval: -604800.0];
    NSDate *thisMonth = [today dateByAddingTimeInterval: -2629743.83]; // Use NSCalendar for

    if (indexPath.row ==2)
    {
        [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@\"(date >= %@) AND (date <= %@)\",thisWeek,today]];
    }
    else if (indexPath.row ==3)
    {
        [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@\"(date >= %@) AND (date <= %@)\",thisMonth,today]];
    }

    // Set the batch size to a suitable number.
    [fetchRequest setFetchBatchSize:20];

    // Edit the sort key as appropriate.
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@\"timeStamp\" ascending:NO];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor,nil];

    [fetchRequest setSortDescriptors:sortDescriptors];

    // Edit the section name key path and cache name if appropriate.
    // nil for section name key path means \"no sections\".
    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
    aFetchedResultsController.delegate = self;
    self.fetchedResultsController = aFetchedResultsController;

    [aFetchedResultsController release];
    [fetchRequest release];
    [sortDescriptor release];
    [sortDescriptors release];

    NSError *error = nil;
    if (![self.fetchedResultsController performFetch:&error])
    {
        /*
         Replace this implementation with code to handle the error appropriately.

         abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application,although it may be useful during development. If it is not possible to recover from the error,display an alert panel that instructs the user to quit the application by pressing the Home button.
         */
        NSLog(@\"Unresolved error %@,%@\",error,[error userInfo]);
        abort();
    }
    NSLog(@\"Number of Objects = %i\",[[fetchedResultsController fetchedObjects] count]);
    return fetchedResultsController;
    NSLog(@\"Number of Objects = %i\",[[fetchedResultsController fetchedObjects] count]);

}    

#pragma mark - Fetched results controller delegate


- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
    [self.logTableView beginUpdates];
}

- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
           atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
    switch(type)
    {
        case NSFetchedResultsChangeInsert:
            [self.logTableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [self.logTableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath
{
    UITableView *tableView = self.logTableView;

    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:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
            break;

        case NSFetchedResultsChangeMove:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{
    [self.logTableView endUpdates];
}
LogResultsViewController
    @implementation LogResultsViewController
    @synthesize fetchedResultsController = __fetchedResultsController;
    @synthesize managedObjectContext;
    @synthesize resultsTableView;
    @synthesize selectedSession;

    - (void)dealloc
    {
        [__fetchedResultsController release];
        [managedObjectContext release];
        [selectedSession release];
        [resultsTableView release];
        [super dealloc];
    }

    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
    }

    #pragma mark - View lifecycle

    - (void)viewDidLoad
    {
        [super viewDidLoad];

        self.resultsTableView.separatorColor = [UIColor grayColor];

        self.resultsTableView.rowHeight = 50;

        [self managedObjectContext];
    }

    - (NSManagedObjectContext *)managedObjectContext 
    {
        if (managedObjectContext != nil) 
        {
            return managedObjectContext;
        }
        NSPersistentStoreCoordinator *coordinator = [(CurlAppDelegate *)[[UIApplication sharedApplication] delegate] persistentStoreCoordinator];   
        if (coordinator != nil) 
        {
            managedObjectContext = [[NSManagedObjectContext alloc] init];
            [managedObjectContext setPersistentStoreCoordinator:coordinator];
        }
        return managedObjectContext;
    }

    - (void)viewDidUnload
    {
        [super viewDidUnload];
        self.managedObjectContext = nil;
        self.fetchedResultsController = nil;
        self.resultsTableView = nil;
    }

    #pragma mark - Table view data source

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
        return [sectionInfo numberOfObjects];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @\"Cell\";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
        }    
        [self configureCell:cell atIndexPath:indexPath];
        return cell;
    }

    - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
    {
        Session *session = (Session *)[__fetchedResultsController objectAtIndexPath:indexPath];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
        [dateFormatter setDateFormat:@\"eeee,MMM d,y\"]; 
        NSString *dateString = [dateFormatter stringFromDate:session.timeStamp]; 

        NSDate *lastDate = session.timeStamp;
        NSDate *todaysDate = [NSDate date];
        NSTimeInterval lastDiff = [lastDate timeIntervalSinceNow];
        NSTimeInterval todaysDiff = [todaysDate timeIntervalSinceNow];
        NSTimeInterval dateDiff = todaysDiff-lastDiff;
        NSTimeInterval dayDifference = dateDiff/86400;
        int days = (int) dayDifference;
        NSLog(@\"%i days\",days);

        cell.textLabel.text = dateString;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.detailTextLabel.text = [NSString stringWithFormat: @\"%i days ago\",days];
        cell.detailTextLabel.textColor = [UIColor colorWithRed:24/255.0 green:83/255.0 blue:170/255.0 alpha:1.0];
        cell.imageView.image = [UIImage imageNamed:@\"11-clock.png\"];
        self.resultsTableView.tableFooterView = [[[UIView alloc] init] autorelease];

        UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"silvercell3.png\"]];
        [cell setBackgroundView:myImageView];
        [dateFormatter release];
        [myImageView release];
    }

    -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (editingStyle == UITableViewCellEditingStyleDelete) 
        {
            // Delete the managed object for the given index path
            NSManagedObjectContext *context = [__fetchedResultsController managedObjectContext];
            [context deleteObject:[__fetchedResultsController objectAtIndexPath:indexPath]];

            // Commit the change.
            NSError *error = nil;

            // Update the array and table view.
            if (![managedObjectContext save:&error]) 
            {
                // Handle the error.
            }
            //[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
        }
    }

    // Override to support conditional editing of the table view.
    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // Return NO if you do not want the specified item to be editable.
        return YES;
    }

    #pragma mark - Table view delegate

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        SessionViewController *sessionViewController = [[SessionViewController alloc] initWithNibName:@\"SessionViewController\" bundle:nil];
        selectedSession = (Session *)[__fetchedResultsController objectAtIndexPath:indexPath];
        sessionViewController.selectedSession = self.selectedSession;
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
        [dateFormatter setDateFormat:@\"MMM d,y\"]; 
        NSString *dateString = [dateFormatter stringFromDate:selectedSession.timeStamp]; 
        sessionViewController.title = dateString;

        [self.navigationController pushViewController:sessionViewController animated:YES];
        [sessionViewController release];
        [dateFormatter release];
    }
#pragma mark - Fetched results controller

- (NSFetchedResultsController *)fetchedResultsController
{
    if (fetchedResultsController != nil)
    {
        return fetchedResultsController;
    }

    // Create the fetch request for the entity.
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    // Edit the entity name as appropriate.
    NSEntityDescription *entity = [NSEntityDescription entityForName:@\"Session\" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];


    // Set the batch size to a suitable number.
    [fetchRequest setFetchBatchSize:20];

    // Edit the sort key as appropriate.
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@\"timeStamp\" ascending:NO];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor,nil];

    [fetchRequest setSortDescriptors:sortDescriptors];

    // Edit the section name key path and cache name if appropriate.
    // nil for section name key path means \"no sections\".
    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
    aFetchedResultsController.delegate = self;
    self.fetchedResultsController = aFetchedResultsController;

    [aFetchedResultsController release];
    [fetchRequest release];
    [sortDescriptor release];
    [sortDescriptors release];

    NSError *error = nil;
    if (![fetchedResultsController performFetch:&error])
    {
        /*
         Replace this implementation with code to handle the error appropriately.

         abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application,[error userInfo]);
        abort();
    }
    return fetchedResultsController;
}    

#pragma mark - Fetched results controller delegate


- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
    [self.resultsTableView beginUpdates];
}

- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
           atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
    switch(type)
    {
        case NSFetchedResultsChangeInsert:
            [self.resultsTableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [self.resultsTableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath
{
    UITableView *tableView = self.resultsTableView;

    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:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
            break;

        case NSFetchedResultsChangeMove:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{
    [self.resultsTableView endUpdates];
}
SessionViewController
@implementation SessionViewController

@synthesize exerciseArray;
@synthesize selectedSession;

- (void)dealloc
{
    [exerciseArray release];
    [selectedSession release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

-(IBAction)showActionSheet {
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@\"Share\" delegate:self cancelButtonTitle:@\"Cancel\" destructiveButtonTitle:nil otherButtonTitles:@\"Twitter\",@\"Facebook\",nil];
    [actionSheet showInView:self.tabBarController.view];
    [actionSheet release];
}

- (void)tweet
{
    SHKItem *aTweet = [SHKItem text:[NSString stringWithFormat: @\"Twitter: testing 1,2,3.\"]];
    [SHKTwitter shareItem:aTweet];
}

- (void)facebook
{
    SHKItem *post = [SHKItem text: [NSString stringWithFormat: @\"Facebook: testing 1,3.\"]];
//    post.URL = [NSURL URLWithString:@\"http://sugarrush-app.com/\"];
    [SHKFacebook shareItem:post];
} 

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIBarButtonItem *actionButton = [[UIBarButtonItem alloc] initWithTitle:@\"Share\" style:UIBarButtonItemStylePlain target:self action:@selector(showActionSheet)];
    self.navigationItem.rightBarButtonItem = actionButton;
    [actionButton release];

    NSSet *exercises = [self.selectedSession valueForKey:@\"exercises\"];
    NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@\"timeStamp\" ascending:YES]];
    NSArray *sorted = [exercises sortedArrayUsingDescriptors:sortDescriptors];
    self.exerciseArray = sorted;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [exerciseArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @\"Cell\";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    Exercise *exercise = (Exercise *)[exerciseArray objectAtIndex:indexPath.row];
    cell.textLabel.text = exercise.name;
    return cell;
}

@end
    

解决方法

        您发布了一个tableView:didSelectRowAtIndexPath:,但是我不认为您告诉我们这是哪个类。 无论如何,该方法似乎都有一个错误:
selectedSession = (Session *)[__fetchedResultsController objectAtIndexPath:indexPath];
sessionViewController.selectedSession = self.selectedSession;
我认为在第一行中,您要说self.selectedSession,假设您继续在此类的dealloc中释放selectedSession。 (这可能不是您唯一的问题) 编辑: 仅当且仅当这些属性是由于从笔尖加载视图而设置的,或者是在loadView或viewDidLoad中设置的,才应在viewDidUnload中将属性设置为nil。您这样做的原因是,在视图控制器的生命周期中,可能多次调用viewDidLoad或loadView。 编辑: 设置fetchedResultsController时,请检查您是否正在使用该属性,并确保未在viewDidUnload上将其设置为nil。     ,        您应该在viewDidUnload中释放或设置为nil的唯一对象是按钮,标签,文本框等。 例如,当您执行self.selectedSession = nil时,它正在为该方法调用发布;这就是属性的要点,它们处理分配和释放。     ,        不要在viewDidUnload中将selectedSession和ExerciseArray设置为nil。 既然这样做,当您尝试释放nil对象时,它将在dealloc中崩溃。 另外,在释放数组之前,最好先调用[array removeAllObjects]。     ,        在viewDidLoad方法中,将self.selectedSession和self.exerciseArray设置为nil。您只应在viewDidLoad中将接口出口设置为nil。但这不是崩溃的原因,因为到解除分配时,您只是将release发送到nil。 您可能需要查看selectedSession对象的内容。您可能在其中一个成员中释放了NSString     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-