A description of the literal in the computer programming language is available at: Http://baike.baidu.com/view/1208327.htm?fr=aladdin.
The following describes the various common literals in OBJECTIVE-C:
#import <Foundation/Foundation.h>intMain (intargcConst Char*argv[]) { /** Below is a basic type literal example*/ intA =Ten;//10 is an integer literal floatf =0.5f;//0.5f is a single-precision floating-point number literal DoubleD =3.14;//3.14 is a double-precision floating-point number literal LongL =100000L;//100000L is a long integer literal Charc ='C';//' C ' is a character type literal Const Char*s ="Hello";//"Hello" for a C string literal /** Below is a composite type literal example*/ structFoo {intA, b;}; //(struct foo) {. A = ten,. B = 20} is a composite type literal of struct foo structFoo Foovar = (structFoo) {. A =Ten,. B = -}; //(int[]) {1, 2, 3, 4} is a composite type literal of an int[4] array int*arr = (int[]){1,2,3,4}; //@ "Hello, world" is the literal of the NSString stringNSString *str =@"Hello, World"; //@[@0, @1, @2] is the literal of a Nsarray object type; @0, @1, @2 are literals of the NSNumber object typeNsarray *array = @[@0, @1, @2];}
The code above can be compiled in LLVM Clang3.4 or later, as well as in Apple LLVM5.0 or later versions.
Examples of literal literals in programming languages in Objective-c