我正在尝试在用户选择对象所在的行后重新分配嵌套值。我基本上改造了阅读收据功能。当我使用它时,它不断抛出一个错误,说“表达式不可分配”:
[[self.conversations objectAtIndex:indexPath.row] valueForKeyPath:@"recipientRead"] = true;
并且当我使用它时,它说“在'id'类型的对象上找不到”属性'recipientRead':
self.conversations[indexPath.row].recipientRead = true;
如何为此键的此索引行访问此对象并为其分配新变量?
这是我的会话对象的样子:
conversations = (
"<Convo: 0x174117970, objectId: kq1H963zwX, localId: (null)> {\n leanId = 7FvjCFbVcv;\n messageBody = Test;\n recipientDisplayName = Ian;\n recipientId = SXeTdhJcRn;\n recipientRead = 0;\n senderDisplayName = user2;\n senderId = rBi8XjVxx5;\n senderRead = 1;\n timeStamp = \"2015-08-18 14:31:48\";\n}",
"<Convo: 0x17410e340, objectId: 4VAkXEJK4i, localId: (null)> {\n leanId = maLdMRcsRS;\n messageBody = \"Test 555\";\n recipientDisplayName = Ian;\n recipientId = SXeTdhJcRn;\n senderDisplayName = user2;\n senderId = rBi8XjVxx5;\n timeStamp = \"2015-08-16 15:38:19\";\n}",
"<Convo: 0x17010f9c0, objectId: Sbct8LnaMg, localId: (null)> {\n leanId = tOYG4Einld;\n messageBody = Test;\n recipientDisplayName = Ian;\n recipientId = SXeTdhJcRn;\n senderDisplayName = user2;\n senderId = rBi8XjVxx5;\n timeStamp = \"2015-08-16 15:32:45\";\n}",
答案 0 :(得分:0)
这是因为.dot符号需要强类型
ClassName *conversation = self.conversations[indexPath.row];
conversation.recipientRead = YES;
只需使用您自己的类名,因为它未在您的示例中指定;)