iphone - 使用不兼容的 void 类型初始化 NSMutableArray __strong

标签 iphone nsmutablearray nsjsonserialization

这就是返回错误的原因:

NSMutableArray *newArray = [[[NSMutableArray alloc] initWithArray:[NSJSONSerialization JSONObjectWithData:[[[appDelegate.Matches objectAtIndex:(NSUInteger)indexPath] objectForKey:@"chat"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]] addObject:[NSDictionary dictionaryWithObjectsAndKeys:message, @"message", [NSString stringWithFormat:@"%llu", appDelegate.userId], @"id", nil]];

最佳答案

“神圣的连续表达, bat 侠!”

如果您将其分成多行,您可以轻松看出问题出在哪里。

或者,更有可能的是,错误会神秘地消失。

问题在于 addObject: 返回 (void),但您试图将该方法的返回值分配给变量。

关于iphone - 使用不兼容的 void 类型初始化 NSMutableArray __strong,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10790531/

相关文章:

iphone - 在 Monotouch 中使用 CoreAnimation 为自定义属性设置动画?

ios - iOS 中的总屏幕解锁时间计算

ios - 如何在 swift 2.0 中从 Dict 中删除重复值

ios - 您将如何编写连续删除按钮的程序?

ios - 如何使用 Objective c 创建多个 tableview 单元格?

objective-c - 当我将对象替换或插入到 nsmutable 数组中时,出现异常

objective-c - 第二次点击后搜索方法不起作用

json - 在 Swift 中获取 JSON

ios - 不同格式的 NSJSONSerialization 数据

swift - 如何在 Swift 中正确获取作用域外的值 Do-Catch(使用 Try)