Purpose of @ Symbol Before Strings?
I've been using Objective-C for a while now, but have never really understood what the purpose of the @ symbol before all strings is. For instance, why do you have to declare a string like this:
NSString *string = @"This is a string";
and not like this:
NSString *anotherString = "This is another string";
as you do in Java or so many other programming languages. Is there a good reason?
It denotes a NSString (rather than a standard C string)
an NSString is an Object that stores a unicode string and provides a bunch of method to assist with manipulating.
a C string is just a \0 terminated bunch of characters (bytes).
EDIT: and the good reason is that Objective-C builds on top of C, the C language constructs need to be still available. @"" is an objective-c only extension.