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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:51:18+00:00 2026-06-13T13:51:18+00:00

I’m currently working on parsing tweets from Twitter in an iOS application. My app

  • 0

I’m currently working on parsing tweets from Twitter in an iOS application. My app currently can perform a search using the search.twitter.com/search.json?... API call, and my app can parse these tweets and select all of the data I want for each tweet. I’m at the phase now where I’m trying to fetch the user’s timeline, but I can’t seem to find a steady way to parse the returned object from the user’s timeline API call.

With the search feature (example returned object at the bottom of: https://dev.twitter.com/docs/api/1/get/search) I can parse by selecting valueForKey:(@"results") and loop through all of those results like so:

    //jSONText is the returned result from the API in NSDictionary format
    NSArray *resultTweetsJSON = [jSONText valueForKey:(@"results")];

    for (int tweetIndex=0; tweetIndex<[resultTweetsJSON count]; tweetIndex++) {

        //Loop through and pull out raw tweet content for a specific tweet
        NSString *rawTweetContent = [resultTweetsJSON objectAtIndex:tweetIndex];

        //Build a custom tweet object using that content
        Tweet *singleTweet = [[Tweet alloc] initWithResultsContent:rawTweetContent];
    }

I was hoping that I could perform the same or similar thing, but I can’t seem to find a good key to use with the returned data from the timeline (example returned data near the bottom of: https://dev.twitter.com/docs/api/1/get/statuses/user_timeline).

As you can see, the user_time result set doesn’t include a nice “results” key that I can query from.

How can I easily select and parse the data from a call to the Get/Statuses/User_Timeline Twitter API and have it converted into an NSArray so that I can loop through and pull out the tweets? Everything online seems to use old techniques. I found this tutorial but it looks like it takes the response from Twitter as an NSData object rather than an NSDictionary object, and I believe NSDictionary is the latest way to do it.

Here’s something I thought might work:

    //No valueForKey to use, so perhaps use ""?
    NSArray *timeline = [jSONText valueForKey:(@"")];

    for (int i=0; i<[timeline count]; i++) {
     //Looping through each "object" of the timeline, grab the tweet content then fill user content

        //Grab the "user" object from the timeline object we're looking at
        NSString *rawUserContent = [[timeline objectAtIndex:i] valueForKey:(@"user")];
        //NSString *rawUserContent = [timeline valueForKey:(@"user")]; - Maybe this?

        //Do whatever else I need to do here...

    }
  • 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-13T13:51:20+00:00Added an answer on June 13, 2026 at 1:51 pm

    After a couple of days, I found out I was just over-complicating the problem. All I needed to do was convert to an array and parse accordingly.

        //The above code was taken out for brevity.  
        //userTimeline = the returned result from the API call to Get User Timeline
        NSDictionary *userTimeline = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonParsingError];
    
        //convert the NSDictionary to an array
        NSArray *timeline = (NSArray*)userTimeline;
    
        //loop through the timeline array object
        for (int i=0; i<[timeline count]; i++) {
            //Looping through each "object" of the timeline, grab the tweet content then fill user content
    
            //Grab the "User" section of the tweet we're looking at
            NSString *rawUserContent = [[timeline objectAtIndex:i] valueForKey:(@"user")];
    
            //Fill singleTweet with user content
            //initWithUserContent is a custom method I wrote to parse apart the User data
            //Tweet is a custom class I wrote to hold data about a particular tweet
            Tweet *singleTweet = [[Tweet alloc] initWithUserContent:rawUserContent];
    
            //At this point singleTweet will be filled with user content, so now fill with tweet content (text and created_at for now)
            singleTweet.text = [[timeline objectAtIndex:i] valueForKey:(@"text")];
            singleTweet.created_at = [[timeline objectAtIndex:i] valueForKey:(@"created_at")];
    

    I then wrapped all of the above code in an if statement. If the user is performing a search (using Twitter’s search API) I perform all of the code in my question above, and if the user is performing a select from the user’s timeline, I perform all of the code in this answer.

    Works like a charm and I can now properly parse both JSON returned results, all I needed to do was convert the dictionary to an array.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can'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.