2012-08-25 33 views
0

由於未捕獲異常'NSInvalidArgumentException'而終止應用程序,原因:' - [__ NSCFType next]:無法識別的選擇器已發送例如' 這個錯誤發生,因爲這行'[self autorelease];「 如果我評論這一行則是例外而不是來了,但應用程序看起來很慢,所以請告訴我,我該怎麼辦寫道,而不是線因未捕獲異常'NSInvalidArgumentException'而終止應用程序,原因:' - [__ NSCFType next]:無法識別的選擇器已發送到實例'

if(sqlite3_step(statement)==SQLITE_ROW) 
{     
    pagestr = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement,0)]; 
    //dateLabel.text=previousDate; 
    //textView.text=pagestr; 
    EditorPage* prev= [[EditorPage alloc] initWithNibName:@"EditorPage" bundle:nil]; 
    prev.dateString= previousDate; 
    prev.bodyString= pagestr; 
    NSArray* array= [[NSArray alloc] initWithObjects:prev,@"forward",nil]; 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"next EditorPage" object:array]; 
    [prev autorelease]; 
}  

回答

1

你們什麼時候做[ self autorelease ]行?我認爲這很不尋常 - 這可能是不正確的。

此消息表示您要發送消息下一個NSCFType的對象。

這樣的消息通常是通過向已釋放的對象發送消息並且其內存隨後被重新分配給不同類型的對象而引起的。

你可以打開殭屍來追蹤這類問題。 另外,您可以將代碼移至ARC以避免保留/發佈問題。

+0

如果(sqlite3_step(報表)== SQLITE_ROW) \t \t \t { \t \t \t \t pagestr = [NSString的stringWithUTF8String:(字符*)sqlite3_column_text(語句,0)]; // \t \t \t \t dateLabel.text = previousDate; // \t \t \t \t textView.text = pagestr; \t \t \t \t EditorPage * prev = [[EditorPage alloc] initWithNibName:@「EditorPage」bundle:nil]; \t \t \t \t prev.dateString = previousDate; \t \t \t \t prev.bodyString = pagestr; NSArray * array = [[NSArray alloc] initWithObjects:prev,@「previous」,nil];};}} \t \t \t \t [[NSNotificationCenter defaultCenter] postNotificationName:@「next EditorPage」object:array]; \t \t \t \t [self autorelease]; \t \t \t} –

+2

您應該將此添加到您的問題中,而不是作爲註釋 - 這是不可讀的。 – nielsbot

+0

但我無法發佈有問題的代碼這就是我發佈here.please幫助我,如果你能 –

相關問題