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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:33:50+00:00 2026-05-18T20:33:50+00:00

Functionality in an iPhone app that searches twitter for some text. The code is

  • 0

Functionality in an iPhone app that searches twitter for some text. The code is very straightforward, I pass the url string to the twitter api, and then parse the result. Although half the time JSON parser fails with errors for Unescaped control character ‘0x0’. Code and full error message below.

    - (void)grabData:(NSString *)searchTerm {
     NSString *urlString = [NSString stringWithFormat:@"http://search.twitter.com/search.json?q=%@&rpp=25",searchTerm];

     NSURL *url = [NSURL URLWithString:urlString];

     NSLog(@"Created url:%@",url);

     //Setup and start async download
     NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
     NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
     [connection release];
     [request release];
    }

    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {

     // Store incoming data into a string
     NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

     //NSLog(@"Did receive some data %@",jsonString);

     //Create a dictionary from the JSON string
     NSDictionary *results = [jsonString JSONValue];

     // Build an Array from the dictionary for easy access to each entry
     NSDictionary *tweets = [results objectForKey:@"results"];

            // Loop through each entry in the dictionary
    for(NSDictionary *tweet in tweets) {
     // Get the user string for the tweet
     NSString *tUser = [tweet objectForKey:@"from_user"];
           NSLog(@"Tweet from %@",tUser);
          }

    }

Error Message from console, 50% of the time, other 50% it works as expected.

2010-12-20 21:22:02.022 TwitterSearch[47362:207] Created url:http://search.twitter.com/search.json?q=red&rpp=25
2010-12-20 21:22:02.361 TwitterSearch[47362:207] -JSONValue failed. Error trace is: (
    "Error Domain=org.brautaset.JSON.ErrorDomain Code=5 \"Unescaped control character '0x0'\" UserInfo=0x4d6a130 {NSLocalizedDescription=Unescaped control character '0x0'}",
    "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Object value expected for key: profile_image_url\" UserInfo=0x4d6a200 {NSUnderlyingError=0x4d6a170 \"Unescaped control character '0x0'\", NSLocalizedDescription=Object value expected for key: profile_image_url}",
    "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Expected value while parsing array\" UserInfo=0x4d6a240 {NSUnderlyingError=0x4d6a1e0 \"Object value expected for key: profile_image_url\", NSLocalizedDescription=Expected value while parsing array}",
    "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Object value expected for key: results\" UserInfo=0x4d6a310 {NSUnderlyingError=0x4d6a2d0 \"Expected value while parsing array\", NSLocalizedDescription=Object value expected for key: results}"
)
  • 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-18T20:33:51+00:00Added an answer on May 18, 2026 at 8:33 pm

    The didReceiveData method can be called multiple times as the data is delivered. So in that method, you should simply append each incoming chunk to an NSMutableData class variable (not process it).

    The processing of the complete data should be done in the connectionDidFinishLoading method.

    The error is probably happening because it is trying to parse a partial block of data.

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

Sidebar

Related Questions

I need to put it some custom logic into my iPhone app so that
I would like to do some functionality like this app for iphone: http://www.ezraschartbooks.com/Site/Home.html I
I'm adding some functionality to my site so that users can upload their own
I have a fairly simple iPhone app that downloads a set of UITableView results
I have written a universal app that's working fine on both iPhone (iPod Touch)
I need to add functionality to my J2EE-based wep application: 1) Take some page,
I'm extending the functionality of a class with a subclass, and I'm doing some
I'm whipping up a short specifications/requirements document for a small prototype iPhone app project.
Some time ago I developed an app for a client. It's basically a simple
What functionality does the yield keyword in Python provide? For example, I'm trying to

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.