Reputation: 1866
i am a beginer in objective c.i found the following line in code and is not able to understand what it does it do, as storeselect has not been used anywhere in the code.
NSString *storeSelect=@"";
Upvotes: 1
Views: 232
Reputation: 22873
NSString *storeSelect=@"Hello World";
is a shortcut of -
NSString *str = [NSString stringWithCString:"Hello World"];
as "stringWithCString" is convenience method it will be automatically adds autoreleased.
Upvotes: 1
Reputation: 18242
It's just assigning an empty string to a variable named storeSelect
. The @""
is for constant strings.
Upvotes: 1
Reputation: 32893
Objective-C builds on C language. In C, quotes are placed around string literals, i.e. "hello". To distinguish NSString and C strings (char pointers, char *
), Objective-C uses @
in front of strings, so @""
is simply empty NSString
. If there was no @
, it would be empty C string, e.g. char *myString = "hello world";
.
Upvotes: 2
Reputation: 104698
storeSelect
is the name of a variable whose type is NSString *
, with the value assigned to @""
Upvotes: 1