Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ^ in objective C mean? [duplicate]

Tags:

objective-c

What does ^ character in Objective C mean? like in the following code

TWTweetComposeViewControllerCompletionHandler 
    completionHandler =
    ^(TWTweetComposeViewControllerResult result) {
        switch (result)
        {
            ...
        }
        [self dismissModalViewControllerAnimated:YES];
    };
like image 997
Firdous Avatar asked Dec 27 '22 06:12

Firdous


1 Answers

It denotes a "block", a piece of code that can be packaged into an object and used later. In your example it specifies a completion handler to be called later, presumably when the user clicks "OK" or some similar button to close an alert.

Blocks can also be used with Grand Central Dispatch and in that case they are used to produce a unit of code that can be run on another thread, both synchronously and asynchronously.

like image 51
Monolo Avatar answered Jan 16 '23 17:01

Monolo