I have this
我有这个
#define sud [NSUserDefaults standardUserDefault]
Then I use [sud integerForKey: key]
然后使用[sud integerForKey: key]
Compile warning:
编译警告:
Class method '+standardUserDefault' not found (return type defaults to 'id')
Run time error:
运行时错误:
+[NSUserDefaults standardUserDefault]: unrecognized selector sent to class 0x3c0bc850
But I can use another one without any warning:
但我可以不用任何警告就使用另一个:
#define man [Manager sharedManager]
where 'man' is the game manager (singleton) to store game score etc
游戏管理员(单例)在哪里存储游戏分数
1 个解决方案
#1
8
It's standardUserDefaults
(with an s).
它是标准用户默认值(带有s)。
Two style notes:
两个风格指出:
- Cocoa discourages the use of abbreviations.
- Cocoa都不鼓励缩写。
- You should consider dropping the macros, as they make code less readable and understandable, as demonstrated by your typo bug.
- 您应该考虑放弃宏,因为它们使代码变得难以读懂和理解,正如您的拼写错误所演示的那样。
#1
8
It's standardUserDefaults
(with an s).
它是标准用户默认值(带有s)。
Two style notes:
两个风格指出:
- Cocoa discourages the use of abbreviations.
- Cocoa都不鼓励缩写。
- You should consider dropping the macros, as they make code less readable and understandable, as demonstrated by your typo bug.
- 您应该考虑放弃宏,因为它们使代码变得难以读懂和理解,正如您的拼写错误所演示的那样。