开发者

EXC_BAD_ACESS while accessing class variable

开发者 https://www.devze.com 2023-03-30 23:42 出处:网络
I have assigned class varaible as.... [MyINFO setUsrID:[dict valueForKey:USERID]]; but when i access \"usrID\"on another view controller it gives EXC_BAD_ACESS error.

I have assigned class varaible as....

  [MyINFO setUsrID:[dict valueForKey:USERID]];

but when i access "usrID" on another view controller it gives EXC_BAD_ACESS error. Please sugges开发者_运维知识库t what changes should be done in MyINFO ?


There's a good Matt Gallagher post about Singletons, along with a clever macro for creating singletons in Objective-C. You can read it here.


Class variables do not work this way in Objective-C. You can create a singleton class and use instance variables of the singleton.

0

精彩评论

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