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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:49:41+00:00 2026-06-07T21:49:41+00:00

I have been struggling with something for weeks and it has brought a real

  • 0

I have been struggling with something for weeks and it has brought a real halt to my progress. I have asked a question a few times on SO, people have been helpful but no-one has cracked what I am doing wrong. It seems a fairly simple thing so hopefully someone out there will have a lightbulb moment and solve this. I am implementing a TWRequest, the result is coming back in a dictionary, I am looping through the results to extract a part of the tweet and creating an array of these ‘text’ components. Straight adter the loop through I am peinting the log of the array – _twitterText and it prints fine. Staright after this method is complete it seems as though _twitterText is being dumped. I have created it in my .h file as a strong property and created an ivar in viewdidload. Still no joy. how do I retain this array to use in another Method?
Here is my .h file….

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "CustomCell.h"
#import "AppDelegate.h"
#import <Twitter/Twitter.h>

@interface MyViewController : UITableViewController <CLLocationManagerDelegate>
{
    CLLocationManager *here;
}

@property(strong) NSDictionary *dict;
@property(strong) CLLocationManager *here;
@property (strong, nonatomic) NSMutableArray *twitterText;

- (void)fetchTweets;

@end </p>

Here is my .m implementation file……

#import "MyViewController.h"

@interface MyViewController ()

@end

@implementation MyViewController
@synthesize dict;
@synthesize twitterText = _twitterText;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    _twitterText = [[NSMutableArray alloc] init];



    here = [[CLLocationManager alloc] init];
    here.delegate = self;
    [here startUpdatingLocation];



    AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];

    NSLog(@"phrase carried over is %@", delegate.a);


    [self fetchTweets];

}

- (void)fetchTweets
{
    TWRequest *request = [[TWRequest alloc] initWithURL:[NSURL URLWithString:
                                                         @"http://search.twitter.com/search.json?q=%40wimbledon"] 
                                             parameters:nil requestMethod:TWRequestMethodGET];


    [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
     {
         if ([urlResponse statusCode] == 200) 
         {
             // The response from Twitter is in JSON format
             // Move the response into a dictionary and print
             NSError *error;        
             NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];
             //NSLog(@"Twitter response: %@", dict);

             NSArray *results = [dict objectForKey:@"results"];


             //Loop through the results
 for (NSDictionary *tweet in results) {
                 // Get the tweet
                 NSString *twittext = [tweet objectForKey:@"text"];

                 // Save the tweet to the twitterText array
                 [_twitterText addObject:twittext];
             }



             NSLog(@"MY ************************TWITTERTEXT************** %@", _twitterText);


         }

         else
             NSLog(@"Twitter error, HTTP response: %i", [urlResponse statusCode]);
     }];



}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"MyCell";
    CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];



    // Configure the cell...
   //cell.venueDetails.text = [_twitterText objectAtIndex:indexPath.row]; 
   NSLog(@"MY ************************OTHER BIT THAT WONT PRINT************** %@", _twitterText);
    return cell;
}
  • 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-07T21:49:42+00:00Added an answer on June 7, 2026 at 9:49 pm

    So the issue here is that your completion handler that you pass to -[TWTweet performRequestWithHandler:] isn’t going to (can’t) fire until the network connection is complete and the server responds to your request. That could take hundreds of milliseconds or even seconds to complete. (Or it may never happen).

    Meanwhile while that is happening, the UITableView wants to draw itself and so will ask you how many sections/rows you have and then will ask you for a cell for each row. So when the table view asks, you should return the actual number of rows you have to draw at that time:

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        // Return the number of rows in the section.
        return [self.twitterText count]; // the actual number of rows we have right now
    }
    

    So then the next step you need is to reload the table when your data is actually in from the server. That will prompt your table view to ask again for the number of sections and rows, and then ask for cells for each section and row. So somewhere in your completion block after you’ve processed all your data you will need to do this:

    dispatch_async(dispatch_get_main_queue(), ^{
    
      // you'll need an outlet to the UITableView
      // here I assume you call that 'tableView'
      // then just ask it to reload on the main thread
    
      [self.tableView reloadData];
    
    });
    

    I hope that helps?

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

Sidebar

Related Questions

I have been struggling with this question for awhile now, and I haven't reached
I have been struggling to find an answer to this theoretical question, even tho
I have been struggling with something which in theory should be very simple for
I have been struggling with this problem for a few days now and I
This is a question I have been struggling with for a while. What is
I have been struggling with these for a few hours now, and have come
something I have been struggling with. I have a tablefield in a database where
I have been struggling with what I think is something simple. I am setting
Bits and bitmask are something I have been struggling to understand for a while,
I've been struggling with this issue for a few weeks now, with no results.

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.