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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:19:26+00:00 2026-05-15T08:19:26+00:00

I am trying to call objectForKey: on an nsdictionary ivar, but I get an

  • 0

I am trying to call objectForKey: on an nsdictionary ivar, but I get an EXC_BAD_ACCESS error.
The nsdictionary is created using the JSON-framework and then retained. The first time I use it (just after I create it, same run loop) it works perfectly fine, but when I try to access it later nothing works. I am doing this code to try to figure out what is wrong:

if (resultsDic == nil) {
    NSLog(@"results dic is nil.");
}
if ( [resultsDic respondsToSelector:@selector(objectForKey:)] ) {
    NSLog(@"resultsDic should respond to objectForKey:");
}

The dictionary is never nil, but it always crashes on respondsToSelector. any ideas?

addition:
These are the other places, besides above, that the dictionary gets interacted with:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    [connection release];

    //get the data in a usable form
    NSString *jsonString = [[NSString alloc] initWithData:downloadedData encoding:NSUTF8StringEncoding];
    resultsDic = [jsonString JSONValue];

    [self processResults];

    NSLog(@"Success. Received %d bytes of data",[downloadedData length]);
    [downloadedData release];
    [jsonString release];
}



- (void)processResults
{
        NSArray *resultsArr = [resultsDic objectForKey:@"results"];
                CLLocationCoordinate2D coordinate = [self coordinateFromResult:[resultsArr objectAtIndex:0]];
        NSLog(@"lat: %f lng: %f", coordinate.latitude, coordinate.longitude);
}

- (void)dealloc {
  [resultsDic release];
  [super dealloc];
}
  • 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-15T08:19:27+00:00Added an answer on May 15, 2026 at 8:19 am

    After somethings retain count is decreased to 0, the object gets deallocated. This is not the same as setting it to nil. It will not be nil. Whilst you can send messages to nil, sending a message to a released object will result in an EXC_BAD_ACCESS error. If you post some of the code where it is created and used, maybe we can help you debug it. Try retaining it twice at the beginning. it’s nit an elegant solution, but it might work as a quick fix.

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

Sidebar

Related Questions

I'm trying to parse this JSON Array: http://www.ifanatic.hu/api/get_recent_posts/?dev=1 But I get this error: 2012-07-15
Im trying to call a function dynamically, using call_user_func_array, but the issue I'm facing
Im trying to call showUIAlertView from myMethod but get an exception: Terminating app due
I am trying to call a webservice using ssl. How do i get the
I'm trying to call a WCF service using soap in IE8 and I can't
I'm trying to call a WCF service cross-domain using javascript, over http. I've added
While trying to call an EJB made using NETbeans (using jdk1.7) from a client
Trying to call from an android client, using the signpost oauth libs. I generated
Im trying to call image_tag image.jpg from devise Mailer template but since its an
I'm trying call qsort in Cython with a custom compare function but I don't

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.