creating objects within a block
[myArray enumerateObje开发者_开发知识库ctsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[[myTreeNode mutableChildNodes] addObject:[NSTreeNode treeNodeWithRepresentedObject:obj]];
//myTreeNode is an NSTreeNode
}];
Is it ok to create objects from within a block?
Yes. It's basically OK to do anything in a block that you might do in a normal function.
精彩评论