Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8836749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:33:57+00:00 2026-06-14T09:33:57+00:00

Hi I always seem to get exception when I use objectAtInded method to retrieve

  • 0

Hi I always seem to get exception when I use objectAtInded method to retrieve NSString from an array. I am reading data from a dictionary which is in the “PropertyList.plist” file.My code is

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"PropertyList"
                                                     ofType:@"plist"];
    names = [[NSDictionary alloc]
             initWithContentsOfFile:path];

    keys = [[[names allKeys] sortedArrayUsingSelector:
             @selector(compare:)] retain];
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger section = [indexPath section];
    NSUInteger row = [indexPath row];

    NSString *key  = [keys objectAtIndex:section];
    NSArray *nameSection = [names objectForKey:key];
    static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SectionsTableIdentifier];
    if(cell == nil)
    {
        cell = [[[UITableViewCell alloc]
                 initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SectionsTableIdentifier] autorelease];
    }
    cell.textLabel.text = [nameSection objectAtIndex:row];
    return cell;
}

The exception happens on the method “cellForRowAtIndexPath” in the line

cell.textLabel.text = [nameSection objectAtIndex:row];

The error message is

Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6832440

The plist file is
enter image description here

Where ever I use “[nameSection objectAtIndex:row];” type of statement it always get exception.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:33:59+00:00Added an answer on June 14, 2026 at 9:33 am

    Like @scorpiozj said ‘names’ contains only key of ‘Root’. So what I did I know is not a very good way to do it. I am sure there is some other way. I changed the ‘viewDidLoad’ method to this,

     - (void)viewDidLoad
    {
        [super viewDidLoad];
        NSString *path = [[NSBundle mainBundle] pathForResource:@"PropertyList"
                                                         ofType:@"plist"];
        names = [[NSDictionary alloc]
                 initWithContentsOfFile:path];
        keys = [names allKeys];
        NSString *key = [keys objectAtIndex:0];
        names = [names objectForKey:key];
        keys = [[[names allKeys] sortedArrayUsingSelector:@selector(compare:)] retain];
        NSLog(@"keys = %@  names = %@",keys,names);
    }
    

    It works! Any idea how to do it better will be appreciated though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I always seem to run into trouble with NSDecimalNumber! Today, I get this error:
For simple 'internal use only' apps, Winforms has a useful default exception handler, which
Here is some sample code...I always seem to get a ClassCastException...anybody point out what
I am trying to get a quicksort method to sort some or partial data.
I always seem to be having fun working with the Ax 2009 product until
JBoss JSF page cache doesn't always seem to be updated when I change my
I'm trying to pass a string to chdir(). But I always seem to have
I've seen examples for load() and ready() , but they always seem to apply
I've been struggling with how to structure my 3-tier applications. I always seem to
In WinForms, to set focus to a specific control, I always seem to wind

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.