KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When writing a method that accepts a block as an argument, do I need to do anything special such as copying the block to the heap before executing it? For example, if I had the following method: - (void)testWithBlock:(void (^)(NSString *))block { NSString *testString = @"Test"; block(testString); } Should I do anything with block before calling it, or when entering the method? Or is the above the correct way of using the passed-in block? Also, is the following way of calling the method correct, or should I do something with the block before passing it? [object testWithBlock:^(NSString *test){ NSLog(@"[%@]", test); }]; Where do I need to copy the block? And how would this have been different if I wasn't using ARC?
Tags (comma-separated)
Save Edits
Cancel