Home > DeveloperSection > Forums > Why we use ^ Symbol in Objective-C?
Pravesh Singh
Pravesh Singh

Total Post:101

Posted on    December-18-2015 12:55 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 647  View(s)
Rate this:
I am beginner in Objective-C, I saw many examples on Obj-C language,  using ^ simbol.
Can anyone tell me what is the use of ^ in Obj-C.
If you give me an example then it will be very helpful for me.

Tarun Kumar

Total Post:214

Posted on    December-18-2015 1:22 AM

^ is called as "Caret". In Objective C, ^ operator is used to declare a block variable and also used to indicate the beginning of a block literal, the body of block is contained within { } (curly braces).
Here is an example with its explanation:

int num1 = 10;
int (^abcBlock)(int) = ^(int num2) {

return num2 * num1;


in this example- Block-name is abcBlock and the return-type of abcBlock is int, the abcBlock has an argument which is also an int.
now, next to the assignment(=) operator, the code ^(int num2)  {  return num2 * num1;  } is a literal block definition having num2 as an abcBlock argument-name, and the code between the { } curly braces is used as the body of the abcBlock.

Modified On Dec-18-2015 01:23:05 AM

Don't want to miss updates? Please click the below button!

Follow MindStick