0
我想在用戶選擇對象所在的行後重新分配嵌套值。我基本上重建一個閱讀收據功能。它不斷拋出一個錯誤,說「表達是不可轉讓」當我使用這個:重新分配嵌套鍵值
[[self.conversations objectAtIndex:indexPath.row] valueForKeyPath:@"recipientRead"] = true;
和它說:「物業‘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}",
很難知道,因爲你不會說'valueForKeyPath:@「recipientRead」'獲取了什麼類型的東西。你的意思是'setValue:forKeyPath:'? – matt
哇哇。謝謝馬特。有沒有辦法將此類型強制轉換爲int類型,因爲它現在拋出「Int'隱式轉換爲'id'不允許使用ARC」? – icscott
首先,沒有'true'這樣的東西。你應該使用'YES'。其次,「YES」不是一個對象。你必須使用'@ YES'。 – matt