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.
Thanks.
Why we use ^ Symbol in Objective-C?
1554
18-Dec-2015
Updated on 18-Dec-2015
Tarun Kumar
18-Dec-2015^ 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:
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.