Increment in Objective-C

Find this useful? Support us: Star on GitHub 6
Category: Number | Language: Objective-C

In Objective-C, there are a few ways to increment a number. Here are some examples:

1. Using the unary operator "++"

``objective-c
int num = 5;
num++; // num is now 6


2. Using the increment operator as a postfix

objective-c
int num = 5;
num = num + 1; // num is now 6

3. Using the increment operator as a prefix

objective-c
int num = 5;
++num; // num is now 6
``

All of these examples achieve the same result of incrementing the value of the variable "num" by 1.