0

In my viewDidLoad method I call a method [self get_shcedule];. This gets some values and stores in an array.

NSArray *filteredArray = [[jsonArray filteredArrayUsingPredicate:predicate] valueForKey:@"hour"];

In the same viewController I have an action define:

- (IBAction)update_schedule:(id)sender

which populates another array incase I wanted to update some of the values.

array2 = [[NSMutableArray alloc]init];

and array2 is sent to same backend server with updated values.

In theory it all works fine, except I am getting a weird bug.

  1. If I don't invoke the action, i.e., don't update the values and leave this particular page on my app. Upon return to this page everything works fine.
  2. If I update the values by calling the action and leave the page and visit another page on my app, upon return to this page I get my values incremented by one.

From my understanding the viewDidLoad method is invoked every time a view is loaded if when we shift between pages on the same app.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
humble_pie
  • 119
  • 10
  • add your code, your question is totally unclear to me. – Ankur Lahiry May 19 '18 at 15:42
  • 1
    How about viewWillAppear and viewDidAppear? Have you made some changes out there? – Karthick Ramesh May 19 '18 at 15:45
  • @KarthickRamesh no actually I deleted both viewWillAppear and viewDidAppear. – humble_pie May 19 '18 at 15:46
  • Can you please add the view controller code! Also what do you mean by “values incremented by one”? – Karthick Ramesh May 19 '18 at 15:47
  • You only get viewdidload when making a new controller and loading it into memory, not every time the view is loaded between pages say because you pushed and popped from the stack. (Effectively [foobarcontroller new]). I would suggest putting into view will appear. But I can’t debug without more info. – Daemedeor May 19 '18 at 16:16

0 Answers0