Best way to pass variables between views

前端 未结 4 1393
走了就别回头了
走了就别回头了 2020-12-21 12:56

I am very new to xcode & Objective-C (having come from PHP) i have started to play around and am finding it very hard to pass variables between views this is what i have

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-21 13:51

    groupName is a member (ivar) of Game_Info. Its default visibility is @protected, so any classes outside Game_Info can't access it, unless they derive from Game_Info. To make groupName accessible, you can either create a property that exposes it, or you can make it @public. How this is done is documented in the vast documentation for Xcode.

    But groupName, being an ivar (instance variable) of an object, only exists if there is in fact an instance of the Game_Info. I assume you have some globally accessible instance of Game_Info in your program, let's call it globalGameInfo. Now you can access its groupName using

    UITextField *gName = [globalGameInfo groupName];
    

提交回复
热议问题