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

  • SEARCH
  • Home
  • 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 5996989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:11:58+00:00 2026-05-23T00:11:58+00:00

I am very new to iPhone development, so please be gentle with me. I

  • 0

I am very new to iPhone development, so please be gentle with me.
I have set up a web service which returns XML data. Sample data:

<categories>
    <category>
        <CategoryId>1</CategoryId>
        <CategoryName>cat1</CategoryName>
    </category>
    <category>
        <CategoryId>2</CategoryId>
        <CategoryName>cat2</CategoryName>
    </category>
</categories>

I was working on the code provided here: http://gigaom.com/apple/tutorial-build-a-simple-rss-reader-for-iphone/
And I’m getting an error.
Here is the function which sets the array:

    -(void)parser: (NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    NSLog(@"ended element: %@", elementName);
    if([elementName isEqualToString:@"category"])
    {
        [category setObject:currentID forKey:@"CategoryId"];
        [category setObject:currentName forKey:@"CategoryName"];
        [categories addObject:[currentElement copy]];
    }
}`-(void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    NSLog(@"Found characters: %@", string);
    if([currentElement isEqualToString:@"CategoryName"])
    {
        [currentName appendString:string];
    }
    else if([currentElement isEqualToString:@"CategoryId"])
    {
        [currentID appendString:string];
    }
}

and I get an error when I try and read from the array:

 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *MyIdentifier = @"MyIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if(cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    }
    int categoryIndex = [indexPath indexAtPosition: [indexPath length] -1];
    [cell.textLabel.text = [categories objectAtIndex: categoryIndex] objectForKey: @"CategoryName"];
    return cell;


}

I get this error:

2011-06-05 11:33:35.436 FirstTry[2419:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString objectForKey:]: unrecognized selector sent to instance 0x4c26b40'

I’m a little lost with the iOS dev thing. Thank you!

  • 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-05-23T00:11:58+00:00Added an answer on May 23, 2026 at 12:11 am

    The reason for "unrecognized selector sent to instance …"-errors is that you are calling a function to an instance which doesn’t implement that function.

    You assume the following structure of your data in cellForRowAtIndexPath: usedLocalVariableName:Class

    categories:NSArray which contains many category:NSMutableDictionary which contains the @"CategoryName"-Key with a NSString value.

    Your Parse-Code results in sth different:

    categories:NSArraywhich contains many currentElement:NSString (I assume that currentElement is a NSString because you are using isEqualToString:-method on currentElement).

    So if you run that code the code-snippet: [categories objectAtIndex: categoryIndex] will return a NSString and not a NSDictionary and NSString does not implement the objectForKey:-method.

    I am not sure (I’ve not tested it) but I think

    [categories addObject:[[category copy] autorelease]];
    

    should work. The autorelease is against memory-leaks

    Another thing: You use

    int categoryIndex = [indexPath indexAtPosition: [indexPath length] -1];
    

    Why not using int categoryIndex = indexPath.row

    edit: You are using the NSXMLParser. I am using the TBXML-Parser which parses faster than NSXML and is more comfortable to use.

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

Sidebar

Related Questions

Very new to Iphone development here, I have a project which is successfully building
I'm very new to iPhone development so please bear with me. I'm following the
I am very new to iPhone development, but I have been given an iPhone
I'm very new to iPhone development and I'm making an application where I have
I am very new to IPhone development. I have upgraded my IPhone to the
I am very new to iPhone/iPad development. can you please help me create this
I'm very new to iPhone development, and I'm trying to write a function which
Im very new to game development on the iPhone... And I have a question:
I'm an iPhone Developer who's quite new to web development so please forgive me
i am very new to iphone development. however i have some experience in flex(flash)

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.