开发者

Class Method Example in objective -c

开发者 https://www.devze.com 2023-02-18 22:48 出处:网络
can anyone tell me how to create a class method 开发者_JS百科and using that how can we share an object DATA in all classes......?A class method has no state therefore can\'t do what you\'re asking for

can anyone tell me how to create a class method 开发者_JS百科and using that how can we share an object DATA in all classes......?


A class method has no state therefore can't do what you're asking for. You want to create a singleton object and pass that around. Check out Singletons, AppDelegates and top-level data for a discussion of singletons and a handy macro for automatically creating them.


-(returnType)methodName; --> this is your normal object method

+(returnType)methodName; --> this will be your class method

[Classname methodName] --> This is how you will call the class method

0

精彩评论

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