David Casseres
David Casseres

Reputation: 143

Obj-c block instantiation

At what time does an Obj-C block become an object? I am guessing that it is instantiated when it is assigned to a variable, passed as a parameter, returned from a function, block, or method, or executed – whichever happens first. But I have never seen documentation on this point.

And as a postscript to this question, is it the same in Swift?

Upvotes: 0

Views: 105

Answers (1)

newacct
newacct

Reputation: 122429

A block doesn't "become" an object. It is an object. A block literal evaluates to a pointer to the block object.

Closures in Swift are not objects.

Upvotes: 2

Related Questions