2011-05-22 66 views
2

在我烤完之前讓我說我已經查看了幾乎所有「無法識別的選擇器發送到實例」的答案,並嘗試了一些建議,但似乎沒有任何工作。所以這是我的問題。NSArrayM長度:發送到實例的無法識別的選擇器

我在viewDidLoad函數中調用我的函數CreateAboutData

-(void)createAboutData 
{ 
    NSMutableArray *aboutText; 

    aboutSections = [[NSMutableArray alloc] initWithObjects:@"About", nil]; 
    aboutText = [[NSMutableArray alloc] init]; 
    //Set About Info 
    [aboutText addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Scoring",@"title",@"Scoring blurb", @"text", nil]]; 

    aboutData = [[NSMutableArray alloc] initWithObjects:aboutText, nil]; 
    [aboutText release]; 
} 

控制器即aboutView由被稱爲我的HomeView控制器。

AboutViewTableController *aboutNavController = [[AboutViewTableController alloc] initWithNibName:@"AboutViewTableController" bundle:nil]; 
    aboutNavController.title = @"About One"; 

    // Create the nav controller and add the view controllers. 
    UINavigationController *theNavController = [[UINavigationController alloc] initWithRootViewController:aboutNavController]; 

    // Display the nav controller modally. 
    [self presentModalViewController: theNavController animated:YES]; <==== THIS IS WHERE IT FAILS 

當代碼失敗它抱怨: - [__ NSArrayM長度]:無法識別的選擇器發送到實例。

@interface AboutViewTableController : UITableViewController { 
    NSMutableArray *aboutData; 
    NSMutableArray *aboutSections; 
} 

-(void)createAboutData; 
@end 

所以,問題是爲什麼會拋出一個例外,我一直在貨架和嘗試不同的途徑無濟於事:

aboutData與createData功能沿如下聲明在標題中。 我也試着用aboutData做一個保留和非原子集的屬性,但同樣的問題出現了。 我也很困惑,因爲沒有在哪裏查詢的長度。 謝謝

+0

除了在'createAboutData',你已經張貼在這裏不應該導致錯誤的代碼中的內存泄漏。發佈表視圖數據源方法'numberOfSections','numberOfRowsInSection','tableView:cellForRowAtIndexPath:'。這些可能是出錯的地方。 – 2011-05-22 05:36:27

+0

我沒有在你的代碼中發現任何錯誤,你指出錯誤發生的地方。我有一個建議,刪除這一行中的空格presentModalViewController:theNavController – Anish 2011-05-22 06:17:49

+0

爲了調試這個,看看對象的實例指針被髮送到無法識別的選擇器(它就在調試器的錯誤消息中),然後查看該NSArray是否是你的一個(來自上面的代碼),或者它是否是系統陣列。這應該有助於縮小範圍。 – ldoogy 2011-05-22 11:24:10

回答

3

嘿,我以前有過這個。某處你正在這樣做:[數組長度];但是數組使用「count」而不是「length」。

獲取混亂與他們的命名慣例有時,通常在OT

相關問題