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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:38:55+00:00 2026-06-03T23:38:55+00:00

my question is: in which function of a view i must execute a code

  • 0

my question is: in which function of a view i must execute a code and be sure all the work of the preceding view has be done? all data saved and whatsoever else?

This is my situation, making me asking this question:
I’ve three view
1) Departure island
2) Arrival Island
3) Map

On the Departure Island you can choose from which island to depart, on the arrival to which you want to arrive, on the Map, you can see visually the route you have to follow in order to reach your destination.
Programmatically, i have the first two view that are two table view (list of string of island name) and the third is a simple image view having a system that draw on it the route. I save data to a simple sql database but i’ve had the same issue saving data more simply using NSUserDefaults.
The two table view save the island choosen at their

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     NSString *islandChoosen= [departureIsland objectAtIndex:indexPath.row];
     [[IslandDatabase database] saveOneRecord:@"1" name:arrivalIslandChoosen];
}

and in the class IslandDatabase

- (void) saveOneRecord:(NSString *)id name:(NSString *)name {

    NSLog(@"Saving data Partenza");
    sqlite3_stmt *statementINSERT;
    NSString somedataToInsertContainingNameofTheIsland;

    NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO aTable somedataToInsertContainingNameofTheIsland"; 
    NSLog(@"%@", insertSQL);

    sqlite3_prepare_v2(database,[insertSQL UTF8String], -1, &statementINSERT, NULL);
    sqlite3_step(statementINSERT);
    sqlite3_finalize(statementINSERT);

}
*Omitting the code of the real query for the sake of simplicity

Now, when i choose the second island i proceed to the map and on the viewDidLoad of the Map i try to get the data of the two island choosen in order to construct my route.
And here it is the problem. I can get the data of the first island choosen but not of the second and it is a matter of time.

I’ve done a lot of tests and it seem that the save of the data i made in the didSelectRowAtIndexPath of the second view (arrival island) actually finish after the viewDidLoad of the third view (map) not giving me the time to get data when i need them for i execute code drawing the route in the viewDidLoad. The NsLog i call at the time of the real writing of the data on the db happen to show after the map view had been designed and launched.

I tried to do a while at the beginning of the third view viewDidLoad which continued till the data of the second island was available but i had no fortune.. it only seem to be stucked before designing the third view…

  • 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-03T23:38:56+00:00Added an answer on June 3, 2026 at 11:38 pm

    You should you try loading your data in the third view using - (void)viewWillAppear:(BOOL)animated instead of - (void)viewDidLoad?

    The viewDidLoad method is called when the controller has loaded its hierarchy into memory, which happens eagerly to optimize performance.

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

Sidebar

Related Questions

I have a question which involves calling a function with 2 parameters of a
I have a question regarding unit testing. I have a function which does the
Question How do you procedurally create a function in Python which takes specific named
I have a view from which I have to select data between 2 given
i have a question in JQuery..I m using $.ajax() in my code (Function 1)
I have a following code which works fine MsgBox(AddSomething(Of String)(Hello, World)) Public Function AddSomething(Of
I have an iOS app in which every time the view is loaded, all
I have a question about the way view caching and browser caching work together
Simple question which I can't seem to find an answer of: I have two
This question relates to this question which I asked earlier this week. The answer

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.