Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSArray #21

Closed
mythodeia opened this issue Mar 16, 2016 · 5 comments
Closed

NSArray #21

mythodeia opened this issue Mar 16, 2016 · 5 comments

Comments

@mythodeia
Copy link

Hello and thanks for the great source code.
I have a question. How can i handle an NSArray in the testrecord for example in your demo?
as i see it i need to add the column in the testtable.m file as well.
how will i add the array in the table?

thanks

@casatwy
Copy link
Owner

casatwy commented Mar 17, 2016

the testrecord is extended from CTPersistanceRecord, but actually, you don't have to do this.

Any object who confirms to CTPersistanceRecordProtocol can be a record, and can be accepted by CTPersistance, even a customized UIView.

so, in your case, you can implement an object who confirms to CTPersistanceRecordProtocol, in - (void)objectRepresentationWithDictionary:(NSDictionary *)dictionary; and - (NSDictionary *)dictionaryRepresentationWithTable:(CTPersistanceTable <CTPersistanceTableProtocol> *)table; you can handle NSArray.

@mythodeia
Copy link
Author

thanks a lot for your answer.
Can you add this case in your existing demo project for everyone to have?
great project
👍

@casatwy
Copy link
Owner

casatwy commented Mar 17, 2016

I think CTPersistanceRecord is the very case of this...

@casatwy casatwy closed this as completed Mar 17, 2016
@mythodeia
Copy link
Author

as i see it i should add the array in the - (NSDictionary *)columnInfo method too.
so should i save the NSArray as a BLOB in the table?

@casatwy
Copy link
Owner

casatwy commented Mar 17, 2016

you can save the array data as a json string, and when you get data from database, you parse this json string into NSArray, while in - (void)objectRepresentationWithDictionary:(NSDictionary *)dictionary.

though sqlite support blob and CTPersistance is based on sqlite,I do not want to support blob type in first place, because I think all blob data like image should be saved as a file, and we save the path of image file in database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants