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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:11:15+00:00 2026-05-28T00:11:15+00:00

I have a UITableView which is populated with some parsed JSON twitter data. The

  • 0

I have a UITableView which is populated with some parsed JSON twitter data. The intent is to have the user select the a row, and have the data passed to a modalViewController, which in this case is a map displaying coordinate and annotation information.

In the debug console I can see the data loaded into each visible UITableViewCell, plus the first one off screen (last loaded). When I run the app, and attempt to select a row, no matter which row I select, the data from the last loaded cell is always the data passed to the modalViewController.

I have logged to ensure the correct row is selected (it is) but no matter which row is selected, the last data loaded is always the data that is pushed.

First the Data Source Methods

#pragma mark -
#pragma mark UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    NSUInteger count = [self.results count];
    return count > 0 ? count : 1;
    }

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    static NSString *ResultCellIdentifier = @"ResultCell";
    static NSString *LoadCellIdentifier = @"LoadingCell";

    NSUInteger count = [self.results count];

    if ((count == 0) && (indexPath.row == 0)) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LoadCellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                      reuseIdentifier:LoadCellIdentifier];
        cell.textLabel.textAlignment = UITextAlignmentCenter;
    }

    if (self.connection) {
        cell.textLabel.text = @"Loading...";
    } else {
        cell.textLabel.text = @"Not available";
    }
    return cell;
}

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ResultCellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                                  reuseIdentifier:ResultCellIdentifier];
   cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.textLabel.numberOfLines = 0;
    cell.textLabel.font = [UIFont systemFontOfSize:14.0];;
}

UIImage *image = [UIImage imageNamed:@"medicaltag.png"];
cell.imageView.image = image;

// Begin UITableCell Data Formatting
NSDictionary *tweet = [self.results objectAtIndex:indexPath.row];

NSString* tweetText = [tweet objectForKey:@"text"];

if ([tweetText rangeOfString:@" *** "].location !=NSNotFound) {

    NSArray *textItems = [tweetText componentsSeparatedByString:@" *** "];

    NSLog(@"%@", textItems);   

    callAddress = [textItems objectAtIndex:0];
    callAddress = [callAddress stringByReplacingOccurrencesOfString:@" , " withString:@", "];
    callType = [textItems objectAtIndex:1];

    NSLog(@"%@", callType);
    NSLog(@"%@", callAddress);

    NSString *latitude = [textItems objectAtIndex:2];
    NSString *latStringPt1 = [[NSString alloc] init];
    NSString *latStringPt2 = [[NSString alloc] init];

    NSString *longitude = [textItems objectAtIndex:3];
    longitude = [longitude stringByReplacingOccurrencesOfString:@"- " withString:@"-"];
    NSString *lonStringPt1 = [[NSString alloc] init];
    NSString *lonStringPt2 = [[NSString alloc] init];

    int latStringLen = [latitude length];
    int lonStringLen = [longitude length];

    NSLog(@"The value of integer num is %i", latStringLen);

    latStringPt1 = [latitude substringWithRange:NSMakeRange(0,latStringLen-6)];
    latStringPt2 = [latitude substringFromIndex:latStringLen-6];
    combinedLatString = [latStringPt1 stringByAppendingString:@"."];
    combinedLatString = [combinedLatString stringByAppendingString:latStringPt2];

    lonStringPt1 = [longitude substringWithRange:NSMakeRange(0,lonStringLen-6)];
    lonStringPt2 = [longitude substringFromIndex:lonStringLen-6];
    combinedLonString = [lonStringPt1 stringByAppendingString:@"."];
    combinedLonString = [combinedLonString stringByAppendingString:lonStringPt2];

    NSLog(@"%@", combinedLatString);
    NSLog(@"%@", combinedLonString);
    }

cell.textLabel.text = [NSString stringWithFormat:@"%@", callAddress];
cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", callType];
cell.detailTextLabel.font = [UIFont systemFontOfSize:14];
return cell;
}

Now the Delegate Method

#pragma mark -
#pragma mark Table View Delegate Methods*

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSUInteger row = [indexPath row];

NSLog(@"%i", row);

CallMapViewController *mapVC = [[CallMapViewController alloc] initWithNibName:@"CallMapViewController" bundle:[NSBundle mainBundle]];
mapVC.annotCallType = callType;
mapVC.annotCallAddress = callAddress;

NSLog(@"%@", mapVC.annotCallType);
NSLog(@"%@", mapVC.annotCallAddress);

NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *lat = [f numberFromString:combinedLatString];
NSNumber *lon = [f numberFromString:combinedLonString];

mapVC.annotLatCoord = lat;
mapVC.annotLonCoord = lon;

NSLog(@"%@", lat);

NSLog(@"%@", lon);

NSLog(@"%@", callType);

NSLog(@"%@", callAddress);


[self presentModalViewController:mapVC animated:YES];


}
  • 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-28T00:11:16+00:00Added an answer on May 28, 2026 at 12:11 am

    You already have your tweet data stored in your viewController’s property results, so you just need to grab the data from there and parse it again (as Daryl Teo mentions) in didSelectRowAtIndexPath:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSString* tweetText = [[self.results objectAtIndex:indexPath.row] objectForKey:@"text"];
        if ([tweetText rangeOfString:@" *** "].location != NSNotFound) {
    
            NSArray *textItems = [tweetText componentsSeparatedByString:@" *** "];
    
            CallMapViewController *mapVC = [[CallMapViewController alloc] initWithNibName:@"CallMapViewController" bundle:[NSBundle mainBundle]]; 
            mapVC.callAddress = [[textItems objectAtIndex:0] stringByReplacingOccurrencesOfString:@" , " withString:@", "];
            mapVC.callType = [textItems objectAtIndex:1];
    
            [self presentModalViewController:mapVC animated:YES];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView which is populated by an array, I have a button
I have an array of objects which populate a UITableView . When a user
I have a UITableView which is populated with an array of objects of type
I have an UITableview which has a description cell populated by an NSString ,
I have a UITableView which loads its data from the web. It takes a
I have got a table view which is populated by json webservice url.I am
I have a UITableView which displays about 5 cells at a time, yet in
I have a grouped UITableView which displays a number of cells, which includes both
I have set up a UITableView-based app, which has a .plist for holding the
I have UITableView.when i click on it's 1 st row one another UITableView opens

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.