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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:42:10+00:00 2026-06-09T16:42:10+00:00

I have been working on a JSON parser for a little while https://github.com/nathanday/ndjson that

  • 0

I have been working on a JSON parser for a little while https://github.com/nathanday/ndjson that parsers a stream of bytes instead of a complete document and convert directly into CoreData entities or custom objects instead of the usual property list objects. I am close to a version 1.0 but I have gotten to a point where to support NSURLConnection connection properly and to make parsing zipped JSON byte streams easier I have to change the way my parse internally works so that it can be called repeated (with the NSData objects the NSURLConnectionDelegate didReceiveData: method for example).
I have two choice that I can think of, the simplest is use a thread to wait on the next piece of data available, or alternately I can rewrite the parsing part of my code so that it can be repeatedly be called, picking up from where it last was by creating my own stake for the variables that need to be maintained between calls.
Using threads is simplest as it doesn’t require very little rewriting if any, but as this is supposed to be a library for general use I am concerned about creating more threads than needed on a resources constrained device like the iPhone. Of cause the other options will make the code more complicated and having to maintain my own stack will not be resource free.
Does anybody have any good advice or maybe another possible options. Is creating threads expensive. Maybe someone can think of a creative way using block, or is it possible to call the NSRunLoop object to execute the next event (NSURLConnectionDelegate methods).

  • 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-09T16:42:11+00:00Added an answer on June 9, 2026 at 4:42 pm

    Under iOS and OS X, Apple provides a great way to do threads without headache: Grand Central Dispatch. Threads aren’t expensive, and the system take care of creating the threads for you.

    You can use serial queues to process your data and then sync it on the main thread using blocks:

    // create the queue that will process your data:
    dispatch_queue_t dataProcessQueue = dispatch_queue_create("data process queue", NULL); // the name is there for debugging purposes
        //dispatch to the newly created queue, and do not wait for it to complete
        dispatch_async(dataProcessQueue, ^{
            //your asynchronous job
            dispatch_async(dispatch_get_main_queue(), ^{
                // the work that has to be done on your main thread using data from above
        });
    });
    // don't forget to release the queue
    dispatch_release(dataProcessQueue);
    

    If you need to do concurrent work, you should use concurrent queues.

    Apple’s documentation is here

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

Sidebar

Related Questions

I have been working on a JQuery script that posts JSON to my asp.net
I have been working with MVC a little while now (2 months) and am
I have been working on a json decode issue (which I have already had
I have been working with SQL Server as a Developer a while. One thing
I have been working on a shopping cart that the user can add/remove order
I have been working on an iPhone app that has a feature of uploading
I have not been working with Monotouch (or the iphone for that matter) for
I have been working in Sencha Touch for a few weeks now, and while
I have an MVC app that I have been working on but I seem
I'm working on an ASP.Net MVC project and have been learning a few little

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.