NSArrayM length : unrecognized selector sent to instance

杀马特。学长 韩版系。学妹 提交于 2019-12-24 03:04:24

问题


Before I get roasted let me say that I have looked at almost all the answers to "unrecognized selector sent to instance" and tried some of the suggestions but nothing seems to work. So here is my question.

I call my function CreateAboutData in the viewDidLoad function.

-(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];
}

The controller i.e. aboutView is called by by my HomeView Controller.

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

When the code fails it complains that:- -[__NSArrayM length]: unrecognized selector sent to instance .

aboutData is declared in the header along with the createData function as follows:

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

-(void)createAboutData;
@end

So the question is why is it raising an exception I have been racking and trying different avenues to no avail. I have also tried making aboutData a property with retain and nonatomic set but the same problem arises. Am puzzled too because no where to query for the length. Thanks


回答1:


Heh, I had this before. Somewhere you're doing this: [array length]; but arrays use "count", not "length".

Gets confusing with their naming conventions sometimes, usually in OT



来源:https://stackoverflow.com/questions/6086127/nsarraym-length-unrecognized-selector-sent-to-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!