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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:26:42+00:00 2026-06-15T20:26:42+00:00

I was wondering, what is the correct approach to saving and sending data. Let’s

  • 0

I was wondering, what is the “correct” approach to saving and sending data. Let’s say, we receive JSON. It’s structure is something like:

  {
    id = 1;
    country_id = 298;
    date = "2012-11-08 14:00:36";
    name = "Mr. Blank";
    profile = "http://somewhere.com/user1234/profile.png";
  }

Now, we have tableView, where in CustomCell we display profile pic, name and country id. On click, we want to transition into detail view, where we show profile picture again, and some other information based on his id (basically new api call).

Now, when we receive this first JSON, we should think about how we save and send values like id and profile pic.

I know 2 approaches, but I’m not sure, if they are “correct”.
First one is, save everything into arrays as soon as your json arrives. So it looks something like this

NSMutableArray *idArr = [[NSMutableArray alloc]init];
NSMutableArray *picArr = [[NSMutableArray alloc]init];

    for (NSDictionary *recDict in jsonResults)
        {
            NSString *personsID = [recDict objectForKey:@"id"];
            [idArr addObject:personsID];
            NSString *pic = [recDict objectForKey:@"profile"];
            [picArr addObject:pic];

        }

This method works, however, it always saves everything what we get in JSON into arrays. So when there are a lot of rows, it takes long time (especially if picture is big). I know, that loading asynchronously may be solution, but I want to talk about principle here.

Another method is passing values straight from selected cell. That means, doing it in method didSelectRowAtIndexPath

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
        MyCustomCell *cell = (MyCustomCell *)[tableView cellForRowAtIndexPath:indexPath];
    imageToSend = cell.profilePic.image; //we have UIImage *imageToSend;
    idToSend = cell.idLabel.text; //we have NSString *idToSend;
    [self performSegueWithIdentifier:@"showDetail" sender:self];
}

Advantage of this approach seems to be, that tableView uses “lazyload” by default(that means, it loads cells as user scrolls down) so in my opinion it saves time when compared to first approach.

Please could you give me some insight as how you pass values? I know that you should use prepareForSegue method, but you don’t have access to indexPath.row there. (So you can identify from where that segue is being called)

  • 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-15T20:26:43+00:00Added an answer on June 15, 2026 at 8:26 pm

    I like the second one better. You don’t need to save all the images, just the URLs. The images should be loaded asynchronously (I use EGOImageLoading) and then you can either send the image or the URL to the new view.

    You can use the tableView indexPathForSelectedRow to pass data from that row:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        NSIndexPath *path = [self.tableView indexPathForSelectedRow];
        YourObject *yourObject = [objectsArray objectAtIndex:path.row];
        [segue.destinationViewController setObject:yourObject];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if this approach was correct : public ITask getState() { statePredicate[Some
I'm wondering what would be the correct approach after executing a command that allocates
I was wondering what is the correct approach, Do I create HiddenInput fields in
I was wondering whether my approach to JSONP is correct and if not, what
I am wondering what is the correct way to approach this. I currently have
i was wondering if i am adopting the correct approach to write to an
just a quick fire question and wondering on the correct approach. In the appConfig
I was wondering what the correct-way is when using a Linq to Sql-model in
I am wondering if there is a correct way to implement the anchor tag
I was wondering where is the correct location to place the App::import on CakePHP2.

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.