Search code examples
iosswiftxcodein-app-purchase

Refresh iOS app when In-App-Purchase purchased


I have an In App Purchase, that, when purchased, needs to reload two View Controllers in my App. however when I try to call their ViewDidLoad() functions, I get a bunch of unexpected nil when opening optional errors, even when I set a TextLabels text to label.text = "0". What am I doing wrong?


Solution

  • You should not call viewDidLoad(), it's not your job to do. If you really wants to reload your whole app, try replacing the rootViewController of your main window which you can find in AppDelegate.

    Or you should try different approach, use Notification (NSNotificationCentre) to throw and listen notifications within app and reload/update the necessary views.