Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the '@' used before strings in Objective-C? [duplicate]

Possible Duplicate:
Purpose of @ Symbol Before Strings?

I've been curious to what @ means before every string is objective C. Is it easier on the compiler, or more efficient in some way?

Example:

NSString* flavour = @"Chocolate"
like image 946
beakr Avatar asked May 24 '12 16:05

beakr


1 Answers

@"Chocolate" is just a shortcut to create an NSString instance. You could also use:

[[NSString alloc] initWithUTF8String:"Chocolate"];

If you didn't use the @ you would create a C string (char array).

like image 110
DrummerB Avatar answered Jan 04 '23 09:01

DrummerB