开发者

What is the best way to keep track of class instances in Objective-C?

I am making an app that uses a class I will call Player the number of Player instances can go up to 10 and down to 2. I am wondering what is the best way to keep track of all of these instances? For now I am just making an array in my view controller that I can add to and remove f开发者_运维技巧rom as necessary, but is there a better way? I was wondering if there is such a thing as class variables as there are class methods?

Thanks in advance.


I discovered that what i needed to do was create another object to manage my child objects. ie Players keeps track of each player instance. I'm new to this OOP world but I think Im figuring things out.


In objective-C the static methods are called as class methods. They all will be called by the class name.

eg:

+(void)classMethod
{

}

[Class classMethod];


You can synchronize properties for your class variables and then use them.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜