作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 JSONModel 调用后发送一个数组。我需要将数组转换为 NSString 并以格式发送数组:
[1, 2, 3]
但是当我将其转换为 NSString 并打印我的数组时,其格式为:
(1, 2, 3)
NSMutableArray *array= [NSMutableArray arrayWithObjects:@"1", @"2",@"3",@"4", nil];
NSString *arraString = [NSString stringWithFormat:@"%@", arr];
NSLog(@"%@",arraString);
如何使用 []
格式创建此内容?
最佳答案
NSMutableArray *array= [NSMutableArray arrayWithObjects:@"1", @"2",@"3",@"4", nil];
NSData *jsond = [NSJSONSerialization dataWithJSONObject: array options:NSJSONWritingPrettyPrinted error:NULL];
NSString *json = [[NSString alloc] initWithData:jsond encoding:NSUTF8StringEncoding];
NSLog(@"%@", json);
关于ios - 如何在 Objective-c 中获取数组类型 [1,2] 而不是 (1, 2)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39539360/
我是一名优秀的程序员,十分优秀!