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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:13:39+00:00 2026-06-10T05:13:39+00:00

I really couldn’t figure out how to deal with iOS5 Twitter API TWRequest performRequestWithHandler.

  • 0

I really couldn’t figure out how to deal with iOS5 Twitter API TWRequest performRequestWithHandler. I declared an instance variable of NSMutableArray *parsedTimeLine in my .h file and a method signature of -(void) fetchWebData: (NSString *) screenName;

The said method implementation is here:

-(void) fetchWebData: (NSString *) screenName {

NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:screenName forKey:@"screen_name"];
[params setObject:@"f" forKey:@"include_entities"];
[params setObject:@"f" forKey:@"include_rts"];
[params setObject:@"10" forKey:@"count"];
[params setObject:@"t" forKey:@"trim_user"];
[params setObject:@"f" forKey:@"contributor_details"];
[params setObject:@"t" forKey:@"exclude_replies"];

NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/user_timeline.json"];

TWRequest *request = [[TWRequest alloc] initWithURL:url
                                         parameters:params
                                      requestMethod:TWRequestMethodGET];
[request performRequestWithHandler:
 ^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {

     if (responseData) {
         NSError *jsonError;

         parsedUserTimeLine =[NSJSONSerialization JSONObjectWithData:responseData
                                                         options:NSJSONReadingMutableLeaves
                                                           error:&jsonError];

         NSLog(@"jsonArray result count inside request: %d",parsedUserTimeLine.count);
         NSLog(@"jsonArray values inside request: %@", parsedUserTimeLine);
     }
 }];   
NSLog(@"jsonArray result count outside request: %d",parsedUserTimeLine.count);
NSLog(@"jsonArray values outside request: %@", parsedUserTimeLine);    

}

This works fine, but there’s a weird thing I really couldn’t figure out. My 2 NSLogs INSIDE the request method shows the accurate count value and array contents of the parsedUSerTimeline. But my 2 NSLogs OUTSIDE THE REQUEST method shows

-jsonArray result count outside request: 0
-jsonArray values outside request: (null)

also, I checked the value of parsedUserTimeLine at my viewDidLoad after calling the fetchWebData method shows count = 0 and value = null.

Kindly help me with this guys. I need to access the value of parsedUserTimeLine globally. Thanks in advance.

  • 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-10T05:13:41+00:00Added an answer on June 10, 2026 at 5:13 am

    I don’t know the Twitter-Framework, but from the code you’ve posted i can tell you that this is going to perform asynchron. The NSLogs are both valid. The inner NSLogs are called when the request has finished, the outer are called even if the request has not been started.

    Simply call a method to inform the others if the request has been finished.

    [request performRequestWithHandler:
     ^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
    
     if (responseData) {
         NSError *jsonError;
    
         NSDictionary *parsedUserTimeLine =[NSJSONSerialization JSONObjectWithData:responseData
                                                         options:NSJSONReadingMutableLeaves
                                                           error:&jsonError];
    
         NSLog(@"jsonArray result count inside request: %d",parsedUserTimeLine.count);
         NSLog(@"jsonArray values inside request: %@", parsedUserTimeLine);
    
         // The request will be perform on another thread, so call the method on the main
         // thread to avoid crossing operations
         [NSOperationQueue mainQueue] addOperationWithBlock:^{
             [self requestHasFinishedWithData:parsedUserTimeLine];
         }]
    
     }
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi there I had a look about before posting and couldn't really figure out
Maybe it's easy, but I couldn't really figure this out right so far... I
I really couldn't figure out a good title for this question, but I have
I couldn't really figure out how to use WWW::Mechanize::TreeBuilder . Basically I get a
I tried searching, but I couldn't really figure out the best search terms to
sorry, I know this question might be too common, but I really couldn't figure
This is a simple question really (but I couldn't seem to find the answer
I think its a rather simple question but I couldn't really find an answer
This is a really simple problem, but I couldn't find a solution anywhere. I'm
I really couldn't find how to resolve the following problem. I have got: <TextBlock

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.