I want to check the pasteboard and show an alert if it contains specific values when the view appears. I can place the code into viewDidLoad
to ensure it's only invoked once, but the problem is that the alert view shows too quickly. I know I can set a timer to defer the alert's appearance, but it's not a good work-around I think.
I checked the question iOS 7 - Difference between viewDidLoad and viewDidAppear and found that there is one step for checking whether the view exists. So I wonder if there's any api for doing this?
Update: The "only once" means the lifetime of the view controller instance.
Try to set a BOOL value, when the situation happens call it.
in somewhere you init AViewController instance:
Not sure why you do this in
ViewDidAppear
? But if you want doSomeStuff is private andsoSomeStuff
was called only once, here is another solution by notification:Then post when somewhere: