2

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

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
cpl593x
  • 21
  • 1
  • 3
  • Except for a memory leak in `createAboutData`, the code you've posted here shouldn't be causing the error. Post the table view data source methods `numberOfSections`, `numberOfRowsInSection`, `tableView:cellForRowAtIndexPath:`. These are the likely places for error. – Deepak Danduprolu May 22 '11 at 05:36
  • i didn't find any error in your code.you point out where the error occur.I have a suggestion to remove spaces in this line presentModalViewController:theNavController – Anish May 22 '11 at 06:17
  • In order to debug this, take a look at the instance pointer of the object being sent the unrecognized selector (it's right there in the error message in the debugger), and see if that NSArray is one of yours (from the code above), or whether it's a system array. That should help you narrow it down. – ldoogy May 22 '11 at 11:24

1 Answers1

3

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

Stephen J
  • 2,367
  • 2
  • 25
  • 31