divendres, 2 de maig del 2014

Objective-C strings




As you know a common way to create strings is using the literal @"Some String" syntax, for instance:

Why is the reason of the @ sign in front of "Porsche"?
Objective-C is like two worlds in one. You can write, even in the same program, Objective-C and C code. 
In C language you can write a String literal this way:
char *amessage = "This is a string literal."; 
For this reason when you write a NSString literal you have to put the @ sign before the string. It's the way to say to the compiler that it is a NSString and not a C language string.
  
Of course, when writing iOS programs it is better to use NSStrings. C-language strings don't have support for Unicode, so you can't use accents or other punctuations signs.

Cap comentari:

Publica un comentari a l'entrada