- #import<Foundation/Foundation.h>
- @interface person : NSObject
- {
- }
- +(person *)instance
- @end
-
-
- @implementation person
-
- + (person *)instance {
- static person *instance;
-
- @synchronized(self) {
- if(!instance) {
- instance = [[person alloc] init];
-
-
- }
- }
-
- return instance;
- }
-
- @end
复制代码
自己写的,只能产生一个类对象,没有mac不知道调试能不能通过。 |
|