iPhone
[objc] block, 큐, 병렬처리
tenn
2013. 11. 19. 13:11
** Global Queue
dispatch_queue_t syncQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(syncQueue, ^{
});
** Main Queue
dispatch_async(dispatch_get_main_queue(), ^{
});
** private Queue
dispatch_queue_t queue; |
queue = dispatch_queue_create("com.example.MyQueue", NULL); |
************
Simple block sample
int x = 123; |
int y = 456; |
// Block declaration and assignment |
void (^aBlock)(int) = ^(int z) { |
printf("%d %d %d\n", x, y, z); |
}; |
// Execute the block |
aBlock(789); // prints: 123 456 789 |
************
...Block:(void(^)(int b, intc))block{
block(1, 2);
}