后端的JSON如下
"data": [
{
"id": 108,
"userId": "84945dd7-4ebe-418a-b5ec-bd418d226778",
"notificationType": 0,
"messagingService": 1,
"status": 2
},
{
"id": 109,
"userId": "84945dd7-4ebe-418a-b5ec-bd418d226778",
"notificationType": 0,
"messagingService": 2,
"status": 2
},
{
"id": 110,
"userId": "84945dd7-4ebe-418a-b5ec-bd418d226778",
"notificationType": 1,
"messagingService": 1,
"status": 2
},
{
"id": 111,
"userId": "84945dd7-4ebe-418a-b5ec-bd418d226778",
"notificationType": 1,
"messagingService": 3,
"status": 2
}
]
我从后端
获取记录到数组@property(nonatomic, strong)NSArray *userPreferences;
我想要成功的是用相同的键显示那些记录" notificationType"在单个单元格中呈现不同类型的其他键" messagingService"。最后点击任何indexPath.row并知道我选择了哪条记录并执行我的主动/非主动选项。
答案 0 :(得分:0)
谢谢你的消息Jordan Bonitatisfor,基于你的例子,这就是我提出的:
strip_attributes except: [:password_digest]
如何将resultDict现在附加到正确的单元格。
答案 1 :(得分:0)
经过严格的测试和试验以及错误后,我设法通过Generics(之前从未使用过)thx的帮助成功完成了我想要的所有帮助。
NSMutableDictionary<NSNumber*, NSMutableDictionary<NSNumber *, KYNotificationPreference *> *> *preferences = [NSMutableDictionary new];
for(NSDictionary *rawPreference in (*response).data){
KYNotificationPreference *preference = [KYDeserializer notificationPreferenceFromSerializedObject:rawPreference];
NSMutableDictionary *notificationTypeDictionary = preferences[@(preference.notificationType)];
if(!notificationTypeDictionary){
notificationTypeDictionary = [NSMutableDictionary new];
[preferences setObject:notificationTypeDictionary forKey:@(preference.notificationType)];
}
[notificationTypeDictionary setObject:preference forKey:@(preference.messagingService)];
}