What does ^ mean in objective C?

What does character mean in Objective-C? as in the following code

TWTweetComposeViewControllerCompletionHandler completionHandler = ^(TWTweetComposeViewControllerResult result) { switch (result) { ... } [self dismissModalViewControllerAnimated:YES]; }; 
+4
source share
3 answers

It stands for “block,” a piece of code that can be packaged into an object and used later. In your example, it indicates a completion handler that will be called later, presumably when the user clicks "OK" or some similar button to close the warning.

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

+8
source

This is a "block", you can read about it in the Apple-Developer-doc , which is mainly used for multithreading.

+2
source

It is used as part of a block definition:

 ^(return_type retval) { statements; } 

You will also see this as part of block declarations.

0
source

Source: https://habr.com/ru/post/1394572/


All Articles