Closed MSch closed 13 years ago
+1, using this all the time in PSFoundation.
Am 22.07.2011 um 12:41 schrieb MSch:
I'd like to add this category on NSObject
- (void)performBlock:(void (^)())block afterDelay:(NSTimeInterval)delay { // For some reason we need [block copy] // http://www.mikeash.com/pyblog/friday-qa-2009-08-14-practical-blocks.html // http://stackoverflow.com/questions/4007023/blocks-instead-of-performselectorwithobjectafterdelay [self performSelector:@selector(_fk_runBlock:) withObject:[block copy] afterDelay:delay]; } - (void) _fk_runBlock:(void (^)())block; { block(); }
Thoughts?
Reply to this email directly or view it on GitHub: https://github.com/foundationkit/FoundationKit/issues/29
+1 on NSObject
category
fyi: PSFoundation already has such a category including performing blocks with one parameter and canceling blocks (although I never tested the canceling)
I don't know about you, but I really like BlocksKit from zwaldowski (which also got forked from foundationkit - organization) und will use it in all future Apps. BlocksKit has adapted the category that was used in PSFoundation, which also supports canceling - so I personally don't see the need to redo this in FoundationKit.
I agree that we should use BlocksKit instead of of redoing everything.
IIRC though I needed to patch BlocksKit to make performBlock: work with ARC.
I'd like to add this category on NSObject
Thoughts?