Assignment Operators

The Objective-C language permits you to combine the arithmetic operators with the assignment operator using the following general format:

op=

In this format, op is any of the arithmetic operators, including +, -, *, /, or %. In addition, op can be any of the bit operators for shifting and masking, discussed later.

Consider this statement:

count += 10;

The effect of the “plus equals” operator += is to add the expression on the right side of the operator to the expression on the left side of the operator and to store the result back into the variable on the left side of the operator. So, the previous statement is equivalent to this statement:

count = count + 10;

The following expression uses the “minus equals” assignment operator ...

Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.