本文转自:水镜先生的网易博客
+(id)shareUserManager
{
static id userManager;
static dispatch_on
ce_t on ceToken; dispatch_on
ce(&on ceToken, ^{ userManager = [[self alloc] init];
});
return userManager;
}
Executes a block object on
void dispatch_once( dispatch_on ce_t *predicate, dispatch_block_t block);
Parameters
-
predicate
-
A pointer to a
de style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102);" >dispatch_on ce_t de> structure that is used to test whether the block has completed or not.
block
-
The block object to execute on
ce.
Discussion
This function is useful for initialization of global da
If called simultaneously from multiple threads, this function waits synchronously until the block has completed.
The predicate must point to a variable stored in global or static scope. The result of using a predicate with automatic or dynamic storage is undefined.