标签:
@interface Model + (int) value; + (void) setValue:(int)val; @end @implementation Model static int value; + (int) value { @synchronized(self) { return value; } } + (void) setValue:(int)val { @synchronized(self) { value = val; } } @end
// Foo.h @interface Foo { } +(NSDictionary*) dictionary; // Foo.m +(NSDictionary*) dictionary { static NSDictionary* fooDict = nil; static dispatch_once_t oncePredicate; dispatch_once(&oncePredicate, ^{ // create dict }); return fooDict; }
标签:
原文地址:http://www.cnblogs.com/songxing10000/p/4822307.html