2011-11-08 37 views
0

你好,我正在從核心數據實體獲取記錄,並在tableview中顯示它。 當我查看記錄並返回時,我的應用程序崩潰,但並非全部時間。 這裏是我的代碼應用程序崩潰與不同類型的異常

//負荷現有歌詞

- (void)loadLyricsForSong { 
    NSMutableArray *arrayOfLyrics = [[NSMutableArray alloc] initWithArray:[song.songLyrics allObjects]]; 
     NSSortDescriptor *nameDescriptor = [[NSSortDescriptor alloc]initWithKey:@"startTime" ascending:YES];//name wise sorting in asecending order 

     NSArray *sortDescriptors = [[NSArray alloc]initWithObjects:nameDescriptor,nil]; 
     [arrayOfLyrics sortUsingDescriptors:sortDescriptors]; 


     [self setLyricsArray:arrayOfLyrics];//setting mutable array with places 
     [nameDescriptor release]; 
     [sortDescriptors release]; //releasing objects 
     [arrayOfLyrics release]; 
     [self.tableView reloadData]; 

    } 

我呼籲viewWillAppear中此loadLyricsForSong方法。併發布lyricsArray在dealloc方法..

和異常

> *** -[UITouchData retain]: message sent to deallocated instance 0x5da0860 
> *** -[NSConcreteNotification retain]: message sent to deallocated instance 0x5d919b0 
> *** -[CFArray retain]: message sent to deallocated instance 0x5b47d30 

請幫助.. 預先感謝

回答

1

什麼是你@property聲明lyricsArray樣子?如果它設置爲assign而不是retain,那麼這段代碼將導致崩潰。確保它設置爲retain

+0

此外,谷歌有關啓用'NSZombies'的信息,因爲這可以讓你保留至少一些關於釋放對象的信息。但是,它會讓您的應用程序消耗更多內存,並且應該關閉生產版本。 – Tim

+0

@property(nonatomic,retain)NSMutableArray * lyricsArray; – iProgrammer

+0

我啓用了NSZombie又' – iProgrammer

相關問題