ios 几种快速写法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | //NSString .... NSString *str1 = @ "str1" ; NSLog (@ "str %@" ,str1); //NSArray NSArray *arr1 = @[@ "one" ,@ "two" ,@ "three" ,@ "four" , @YES ,@( NO ), @1 ,@(2)]; NSLog (@ "count %d" ,arr1.count); NSLog (@ "value %@" ,arr1[4]); //NSMutableArray NSMutableArray *arr2 = [@[@ "oo" ,@ "xxx" ] mutableCopy]; /*[@[@(1), @(2), @(3), @(4), @(5), @(6), @(7), @(8), @(9), @(10)] mutableCopy] NSMutableArray *arr2 = [@[ [@{@"name" : @"Cersei Lannister", @"title" : @"Queen of the Seven Kingdoms", @"isFavourite" : @NO, @"image" : @"cersei" } mutableCopy], [@{@"name" : @"Jaime Lannister", @"title" : @"Kingslayer", @"isFavourite" : @NO, @"image" : @"jaime" } mutableCopy], [@{@"name" : @"Joffrey Baratheon", @"title" : @"The Illborn", @"isFavourite" : @NO, @"image" : @"joffrey" } mutableCopy], [@{@"name" : @"Tyrion Lannister", @"title" : @"The Halfman", @"isFavourite" : @NO, @"image" : @"tyrion" } mutableCopy], [@{@"name" : @"Tywin Lannister", @"title" : @"Lord of Casterly Rock", @"isFavourite" : @NO, @"image" : @"tywin" } mutableCopy]] mutableCopy]; */ [arr2 addObject:@ "two" ]; NSLog (@ "count %d" ,arr2.count); NSLog (@ "value %@" ,arr2[1]); //NSDictionary NSDictionary *dic1 = @{@ "key1" :@ "value1" ,@ "key2" :@ "value2" }; NSLog (@ "count %d" ,dic1.count); NSLog (@ "value %@" ,dic1[@ "key1" ]); //NSMutableDictionary NSMutableDictionary *dic2 = [@{@ "key1" :@ "value1" ,@ "key2" :@{@ "key22" :@ "value22" ,@ "key222" :@ "value222" }} mutableCopy]; NSLog (@ "count %d" ,dic2.count); NSLog (@ "value %@" ,dic2[@ "key2" ][@ "key222" ]); |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 现代计算机视觉入门之:什么是图片特征编码
· .NET 9 new features-C#13新的锁类型和语义
· Linux系统下SQL Server数据库镜像配置全流程详解
· 现代计算机视觉入门之:什么是视频
· 你所不知道的 C/C++ 宏知识
· 不到万不得已,千万不要去外包
· C# WebAPI 插件热插拔(持续更新中)
· 会议真的有必要吗?我们产品开发9年了,但从来没开过会
· 【译】我们最喜欢的2024年的 Visual Studio 新功能
· 如何打造一个高并发系统?