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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:49:42+00:00 2026-05-13T23:49:42+00:00

I access a RESTFUL url and get back results. The results are in JSON.

  • 0

I access a RESTFUL url and get back results. The results are in JSON. I turn the response into a string via:

- (void)connectionDidFinishLoading:(NSURLConnection   *)connection {
NSString *json = [[NSString alloc] initWithBytes:[self.receivedData mutableBytes] length:[self.receivedData length] encoding:NSUTF8StringEncoding];

The json variable has a value of 0x0. When I mouse over it, I see <Invalid CFStringRef>. How can I debug this to tell why it is invalid? I render the JSON given back through the browser in A JSON parser. That checks out fine.

Results are given back by entering an ID in the URL. Other IDs return results without issue. The result set is fairly large.

  • 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-13T23:49:43+00:00Added an answer on May 13, 2026 at 11:49 pm

    First I would use initWithData:encoding: to setup the NSString. Small difference, but that method is there for a reason.

    Then, I would do a hexdump of self.receivedData to see what is actually in there. If that data is not properly UTF8 encoded then the initWithData:encoding: will fail.

    (Google for NSData hex dump to find other people’s utility functions to do this)

    I have found that sometimes web services are sloppy with their encoding. So I usually implement a fallback like this:

    NSString* html = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
    if (html == nil) {
        html = [[NSString alloc] initWithData: data encoding: NSISOLatin1StringEncoding];
        if (html == nil) {
            html = [[NSString alloc] initWithData: data encoding: NSMacOSRomanStringEncoding];
        }
    }
    

    It is kind of sad that this is required but many web services are not written or configured properly.

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

Sidebar

Related Questions

Is it possible to get spelling/search suggestions (i.e. Did you mean) via the RESTful
I need to access a RESTful server, which is not created with WCF. For
I am trying to access a restful web service using jQuery Ajax but getting
Is there any differences between Restful URL web services if you use embedded HTTP
I have a web application that uses RESTful url patterns. Currently if a users
I'm attempting to receive a response from a restful service, but receive a timeout.
When i tried to access Restful web service using JAXRS on localhost, I am
I need to send HTTP requests with all the standard RESTful methods and access
We're designing the URL structure for our web app and want to use RESTful,
In my knowledge, the RESTful WCF still has .svc in its URL. For example,

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.