-1
-(void)Complete{
    CM(@"complete");
    [BNUtilitiesQuick UtilitiesQuick].startForm=0;
    [self.view removeFromSuperview]; //This remove superView and the new view will be listNewController

    [self setSearchLocationWhenChangeSearchBar];
    if([self.searchListTemp isEqualToString:[cachedProperties singleton].searchList] && [self.searchLocationTemp isEqualToString:[cachedProperties singleton].searchLocation]){
        CLog(@"Don't do anything");
    }
    else{
        ...
//Blablabla
        //[Timer searchCriteriaChanged];
    }
[[BNUtilitiesQuick ListController] viewWillAppear:true];//It's not called if I don't do this

}

Part of me feel that it should be called automatically. Somehow I must have done something wrong when it's not called.

Obviously I don't want things to get called twice either.

So I ended up calling them explicitly. Somehow it feels wrong. Am I wrong?

user4951
  • 32,206
  • 53
  • 172
  • 282
  • You are very wrong. Most definitely about using the singleton on listNewController too. – Eimantas Jun 25 '12 at 08:35
  • that singleton thingy is experimental. I use a different style most people are more familiar with. So I am wrong. Does that mean that viewWillAppear should have been called implicitly? – user4951 Jun 25 '12 at 08:37
  • just a question :) what is the parent class of your BNUtilitiesQuick ? – janusfidel Jun 25 '12 at 08:39
  • @interface BNUtilitiesQuick:NSObject{ } it's purpose is to just store the controllers for the applications – user4951 Jun 25 '12 at 08:43
  • 1
    viewWillAppear is declared in UIViewController.h , it gets called automatically every time the view is about to appear. at some point you have to use super in your implementation.that could be the reason why its not called automatically, because your BNUtilitiesQuick is not a class of UIViewController – janusfidel Jun 25 '12 at 08:49

2 Answers2

0

If you want some action to happen just before your view disappears, you can write your code in the viewWillDisappear method. This method notifies the view controller that its view is about to be removed from a view hierarchy.

- (void)viewWillDisappear:(BOOL)animated{}
Pradeep Reddy Kypa
  • 3,992
  • 7
  • 57
  • 75
0

viewWillAppear is declared in UIViewController.h , it gets called automatically every time the view is about to appear. at some point you have to use super in your implementation.that could be the reason why its not called automatically, because your BNUtilitiesQuick is not a class of UIViewController

janusfidel
  • 8,036
  • 4
  • 30
  • 53
  • That's the problem. It doesn't get called automatically in my case. I ALWAYS have to call that explicitly. For some reason it's never called explicitly. – user4951 Jun 25 '12 at 11:07
  • [BNUtilitiesQuick ListController] is of type lilstController and is indeed a subclass of UIViewController. – user4951 Jun 25 '12 at 11:08
  • what happens when you call [super viewWillAppear] in your BNUtilitiesQuick? – janusfidel Jun 25 '12 at 11:13
  • BNUutilities quick do not have viewWill appear. [BNUtilitiesQuick ListController] does. And yes I call [super ViewWillAppear] there. But the original is not called unless I do it explicitly. – user4951 Jun 25 '12 at 11:38