It means the parameter is used to send data in
but also to get data out
.
Let's see an example implementation:
- (void)increment:(inout NSUInteger*)number {
*number = *number + 1;
}
NSUInteger someNumber = 10;
[self increment:&someNumber];
NSLog(@"Number: %u", someNumber); //prints 11
This pattern is often used with C structures, e.g CGPoint
because they are passed by value (copied).
Also note that inout
is not absolutely required there but it helps the compiler to understand the meaning of your code and do better job when optimizing.
There are also separate in
and out
annonations but as far as I know there are no compiler warnings when you misuse them and it doesn't seem Apple is using them any more.