How would you read this in English? My concern is with the pointer. Is that pointer associated with char or with string?
Thanks in advance!
How would you read this in English? My concern is with the pointer. Is that pointer associated with char or with string?
Thanks in advance!
The part in parentheses describes the type of the parameter immediately following it—in this case, a pointer to some char
s.
it's a pointer to char parameter named string.
So:
char *
is the type of the parameter following itstring
is the name of the parameter (and you should refer to this one in method body)The parameter is a C string, which is also named string.
[obj initWithName: "whatever"];
C strings are a '\0'
terminated sequence of chars, and are declared as char *
.
char *foo = "a C string";
NSString *bar = @"an objc string";
string is just the name of the parameter.
The type of the parameter is a pointer to a char
.