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 7970543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:24:58+00:00 2026-06-04T07:24:58+00:00

I keep getting the following error: *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’,

  • 0

I keep getting the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setLinkID:]: unrecognized selector sent to instance 0x6bf37e0'

I’m using NSXMLParser to parse an XML document, and when I run across the tag “link”, I am creating a custom JLink object and passing the parser delegate along to that object. This method was working fine and then I must have done something because now it is suddenly producing the error above every time I run the project.

I’ve been pulling my hair out, but I think that the JLink object is being released and therefore when the method setLinkID: is called, the program crashes. Has anybody else had this problem or know what may be the problem? My code is below:

Method that is causing the error (most of the) time but sometimes it changes:

-(void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
  if ([elementName isEqual:@"linkID"]) {
    currentString = [[NSMutableString alloc] init];
    [self setLinkID:currentString];
  } else if ([elementName isEqual:@"userID"]) {
    currentString = [[NSMutableString alloc] init];
    [self setUserID:currentString];
  } else if ([elementName isEqual:@"url"]) {
    currentString = [[NSMutableString alloc] init];
    [self setLink:currentString];
  } else if ([elementName isEqual:@"displayText"]) {
    currentString = [[NSMutableString alloc] init];
    [self setText:currentString];
  }
}

And the method that is creating JLink and making it the parser’s delegate:

-(void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
  if ([elementName isEqual:@"userID"]) {
    currentString = [[NSMutableString alloc] init];
    [self setUserID:currentString];
    [links removeAllObjects];
  } //A bunch of other checks
  else if ([elementName isEqual:@"link"]) {
    JLinks* newLink = [[JLinks alloc] init];
    //Setup the parent so that we can regain control of the element
    [newLink setParentParserDelegate:self];
    [parser setDelegate:newLink];
    [[self links] addObject:newLink];
  }
}

I’m using ARC. Thanks

  • 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-04T07:24:59+00:00Added an answer on June 4, 2026 at 7:24 am

    OK, the error says

    -[__NSCFString setLinkID:]: unrecognized selector sent to instance 0x6bf37e0
    

    Note that you’re somehow sending the setLinkID: message to an instance of __NSCFString (basically a private subclass of NSString).

    In your code, you are only sending setLinkID: to self. So, somehow your parser delegate has been deallocated and, in its place, an instance of NSString has been allocated.

    Even if you’re using ARC, you still have to understand object ownership. In this case, the NSXMLParser does not retain a reference to its delegate, because that would very likely create a retain cycle. If you look in the headers or the documentation you will see that the property is defined as a weak reference.

    What I think is happening is that you set up the parser, you have no other strong reference to the main parser delegate, so shortly after parsing begins, it is deallocated. You need to go through your code and make sure you have a strong reference to that main parser delegate.

    You will have problems if you do this:

    NSXMLParser *parser = ...
    [parser setDelegate:[[MyParserDelegate alloc] init]];
    // delegate immediately deallocated, no strong references to it
    if ([parser parse]) {
        MyParserDelegate *delegate = [parser delegate]; // nil or junk at this point
    

    You should structure your code like this:

    NSXMLParser *parser = ...
    MyParserDelegate *topLevelDelegate = [[MyParserDelegate alloc] init];
    [parser setDelegate:topLevelDelegate];
    if ([parser parse]) {
        // pull data out of topLevelDelegate
    

    If you use the pattern of swapping in specialized delegates, the topLevelDelegate needs to maintain a strong reference to the child delegates. If you have a strong reference from the child to the parent, it won’t matter, because the child itself will only be reachable from the parser itself, which doesn’t retain its delegate. You will probably need a reference both ways: strong from parent to child; weak from child to parent. (In general, this pattern will prevent retain cycles.)

    Oh, to answer your title question: Yes, it’s possible for ARC to release memory you are using, if it is only reachable by weak references to it. But if you’re using it, you should have at least one strong reference to it.

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

Sidebar

Related Questions

When I deploy my application to GoogleAppEngine I keep getting the following error Uncaught
For some reason i keep getting the following error when i try to set
I keep getting the following error when trying to deploy my app with the
I keep getting the following error: AttributeError: Caribou instance has no attribute 'on_key_up' The
I keep getting the following error message ERROR 1064 (42000): You have an error
I keep getting the following error when trying to build the masstransit source from
I keep getting the following error when trying to run a login script I
I'm trying to get http://www.gelens.org/code/gevent-websocket/ running and keep getting the following error. socket_id=1 already
I'm using Visual Studio 2008 Express edition, and keep getting the following error: Cascadedisplay.h(4)
I keep getting an error with the following bit of code. It is probably

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.