我有一个自定义类 QBChatDialog 对象,我将其存储在 sqlite 数据库中,例如
-(void)storeInDB:(QBChatDialog *)dialog {
NSString *query = = [NSString stringWithFormat:@"INSERT INTO dialogs (dialog_id,last_message) VALUES ('%@','%@')",dialog.ID,dialog.lastMessageText];
//run the query
}
然后我从数据库中检索 NSDictionary 。
// after fetching as an array in dbrecord
NSDictionary *dialogDictionary = @{@"dialog_id":[dbrecord objectAtIndex:DIALOG_ID_INDEX],
@"dialog_last_message":dbrecord objectAtIndex:DIALOG_LAST_MESSAGE_INDEX]
};
如何将其映射回QBChatDialog
类,以获取类似dialog.ID
or的值dialog.lastMessageText
。该类是第三方 API,一些属性是read-only
.
谢谢