Best way to pass variables from one Swift class to another?
问题 Suppose I define variable in one class, ViewController , and want to access that variable from another class, say BLEHandler . How do I go about doing that? I've had trouble with NSUserDefaults , so a method besides that would be greatly appreciated. 回答1: There are may ways you can pass value between viewControllers For example PrepareForSegue NSNotificationCenter Delegate Singleton Different way is used in different case. If you use prepareFoSegue - is used when you want to pass when perform