I've a custom class QBChatDialog object, that I'm storing in sqlite database like
-(void)storeInDB:(QBChatDialog *)dialog {
NSString *query = = [NSString stringWithFormat:@"INSERT INTO dialogs (dialog_id,last_message) VALUES ('%@','%@')",dialog.ID,dialog.lastMessageText];
//run the query
}
Then I'm retrieving as NSDictionary from database.
// 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]
};
How can I map it back to QBChatDialog
class, to get values like dialog.ID
or dialog.lastMessageText
. The class is third party API, and some properties are read-only
.
Thanks
You don't need to set readonly properties, so you can basically unwrap your NSDictionary, just make sure you for sure store dialog id and it's type, so that you can start with this code:
And after that just set every field you need, that is not readonly, e.g.: