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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:36:45+00:00 2026-06-09T17:36:45+00:00

I’m relatively new to Objective-C, and followed a tutorial on an introduction to MapKit

  • 0

I’m relatively new to Objective-C, and followed a tutorial on an introduction to MapKit (located here). I’ve been trying to debug an issue with a JSON string being passed to an NSDictionary. I’m getting the following error:

2012-08-13 11:18:30.370 ArrestsPlotter[76578:c07] -[__NSCFString JSONValue]: unrecognized
selector sent to instance 0x73a6400
2012-08-13 11:18:30.372 ArrestsPlotter[76578:c07] *** Terminating app due to uncaught 
exception 'NSInvalidArgumentException', reason: '-[__NSCFString JSONValue]: unrecognized 
selector sent to instance 0x73a6400'
*** First throw call stack:
(0x17b4022 0x131bcd6 0x17b5cbd 0x171aed0 0x171acb2 0x34782 0x35351 0x1c65e 0x17b5e42 
0xda49df 0x178894f 0x16ebb43 0x16eb424 0x16ead84 0x16eac9b 0x1ddd7d8 0x1ddd88a 0x47e626 
0x3403d 0x20f5)
terminate called throwing an exception

I’ve narrowed it down to this line that’s giving me the issue:

NSDictionary * root = [responseString JSONValue];

According to the SBJSON library documentation, this is possible. I’m thinking it has something to do with the string that I’m passing to the NSDictionary. Here is the code that creates the JSON string:

// 1
MKCoordinateRegion mapRegion = [_mapView region];
CLLocationCoordinate2D centerLocation = mapRegion.center;

// 2
NSString *jsonFile = [[NSBundle mainBundle] pathForResource:@"command" ofType:@"json"];
NSString *formatString = [NSString stringWithContentsOfFile:jsonFile encoding:NSUTF8StringEncoding error:nil];
NSString *json = [NSString stringWithFormat:formatString,
                  centerLocation.latitude, centerLocation.longitude, 0.5*METERS_PER_MILE];

// 3
NSURL *url = [NSURL URLWithString:@"http://data.baltimorecity.gov/api/views/INLINE/rows.json?method=index"];

// 4
ASIHTTPRequest *_request = [ASIHTTPRequest requestWithURL:url];
__weak ASIHTTPRequest *request = _request;

request.requestMethod = @"POST";
[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request appendPostData:[json dataUsingEncoding:NSUTF8StringEncoding]];
// 5
[request setDelegate:self];
[request setCompletionBlock:^{
    NSString *responseString = [request responseString];
    NSLog(@"Response: %@", responseString);
    [self plotCrimePositions:responseString];

The string is getting populated correctly, and in the terminal it is showing like this (The whole thing is huge, so I’ll only post a small amount):

2012-08-13 11:18:30.210 ArrestsPlotter[76578:c07] Response: {
"meta" : {
"view" : {
  "id" : "zzzz-zzzz",
  "name" : "Inline View",
  "attribution" : "Baltimore Police Department",
  "attributionLink" : "http://www.baltimorepolice.org/",
  "averageRating" : 0,
  "category" : "Crime",
  "licenseId" : "CC_30_BY",
  "numberOfComments" : 0,
  "oid" : 0,
  "publicationAppendEnabled" : false,
  "publicationStage" : "unpublished",
  "rowsUpdatedAt" : 1338813661,
  "rowsUpdatedBy" : "n22b-663u",
  "signed" : false,
  "tableId" : 354024,
  "totalTimesRated" : 0,
  "viewType" : "tabular",
  "columns" : [ {
    "id" : -1,
    "name" : "sid",
    "dataTypeName" : "meta_data",
    "fieldName" : ":sid",
    "position" : 0,
    "renderTypeName" : "meta_data",
    "format" : {
    }
  }, {
    "id" : -1,
    "name" : "id",
    "dataTypeName" : "meta_data",
    "fieldName" : ":id",
    "position" : 0,
    "renderTypeName" : "meta_data",
    "format" : {
    }
  }

Any help would be appreciated. I realize the tutorial I’m using is a little outdated, but I’ve never worked with JSON before, so I’m not really sure what the issue is.

  • 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-09T17:36:46+00:00Added an answer on June 9, 2026 at 5:36 pm

    The issue is caused by trying to send the message JSONValue to an instance in NSString, which doesn’t support this method. try the following code instead

    SBJsonParser *jsonParser = [[SBJsonParser alloc] init];
    NSError *error = nil;
    NSArray *jsonObjects = [jsonParser objectWithString:responseString error:&error];
    

    This should give you an NSArray of NSDictionaries containing the response data.

    You can also try copying and pasting your entire JSON response here to check it valid

    http://jsonformatter.curiousconcept.com/

    EDIT: Although as some of the other answers point out, #importing SBJSON.h should add the JSONValue method to NSString class dynamically by using a category. Explained here

    http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/chapters/occategories.html

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

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.