I've read that _
(underscore) is only used to tell that the variable/method/class is for the API use only and should not be used by other programmers.
What about __
(double underscore)?
In this example __block BOOL found = NO;
From the Apple Docs about Block Objects .
Also, can anyone help me understand the concept of pointer-to-pointers ? **var
I've read some answers about it but didn't really get it. When and how should I use it?
Single underscore is traditionally used for private API (methods and sometimes ivars). Their main purpose is to prevent name collisions.
__block
is a keyword for the new blocks API. In general, double underscore keywords are for the compiler.
For pointers to pointers the NSError
is a good example: When a method wants to return a new NSError
object as part of its parameters (not return value), you need a pointer to a variable of type NSError *
, so that you can assign it. With a simple pointer you could only access the object, but not (re-)assign it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.