int main(int argc, const char * argv[]) {
@autoreleasepool { //1.字面值、字面量 LLVM新的语法特性 //1.NSString 类 字面值 NSString *string = @"Hello World!!"; //2.NSNumber 类 使用子面值表示NSNumber对象 NSNumber *myInt = @100;//数字前加一个@ NSNumber *myFloat = @3.14f;//小数前加一个@ NSNumber *myDouble = @3.1415926; NSNumber *myChar = @'A'; NSNumber *myUInt = @128ul; //3.输出 NSLog(@"string = %@",string); NSLog(@"myInt = %@",myInt); NSLog(@"myFloat = %@",myFloat); NSLog(@"myDoble = %@",myDouble); NSLog(@"myChar = %@",myChar); NSLog(@"myUInt = %@",myUInt); //4.NSArray 类与字面值 NSArray *array = [NSArray arrayWithObjects:@"1",@"2",nil]; NSLog(@"%@",array); //使用字面值创建的数组 NSArray *newArray = @[@"1",@"2"]; NSLog(@"%@",newArray); //访问数组元素的方法 NSString *value = [array objectAtIndex:0]; NSLog(@"value = %@",value); //LLVM支持新的语法访问数组元素 NSString *newValue = array[0]; NSLog(@"newVlaue = %@",newValue); //5.字典和字面值 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1",@"key1", nil]; NSLog(@"count = %lu",dict.count); //字面值方式创建字典 NSDictionary *newDict = @{@"value1":@"key1",@"value2":@"key2"}; NSLog(@"count = %lu",newDict.count); //LLVM支持新的访问key值的方式 NSLog(@"%@",newDict[@"key2"]); } return 0; } |