Any pointers/suggestions for porting Objective-C ^{blocks;}?

Any pointers/suggestions for porting Objective-C ^{blocks;}?
0.0 0


People are really loving those Objective-C blocks. Right now, when I port some code I find for cocos2d-iphone that has them, I make a class to act as a functor (+ reference holder for referenced objects) — but this is often a pain. Not to mention it’s a pain to make sure that object stays around until it’s no longer needed.

Does anyone have any tricks/suggestions/pointers to make this easier in general?

[ Functor = Function Object = ]


Code block needs compiler block support,manual function pointer is hard to supply the same funcionality,


Well, C*+ isn’t going to get that — it’s tied to the reference counting of Objective-C.
User supplied blocks have to be dealt with via function callbacks as far as I can see.
I was more talking about internal usage of block in porting cocos-iphone or extensions people have written. Where you have the code, and will have to replace it with a C*+ construct.

As I’m writing, I guess we could make an object that you could register CCObject*’s with, and it would take a function call….