开发者

How to share properties between different classes in objective-c?

what do i have to do if i want to acess or change properties of one 开发者_运维技巧class in different controllers?icreated a class info,with two properties,teams and players,,For example,i wanna set number of teams in one controller,number of players in another an then use them in the third one?how to manage that?


You will have to reference that class. Go to the .h file and type above @interface of MyClassTwo...

@class MyClassOne

And you create and object for MyClassOne inside the @interface of MyClassTwo and set that as a property and synthesize it

Now in the @implementation of MyClassTwo, you should be able to the access the properties of MyClassOne with the object of MyClassOne.


You would normally create model, an NSObject to hold the 'state' of your data and this can then be used by all of your controllers to render. The model will have properties for teams, players etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜