This may seem like a weird question but thought I would ask here before I spend a couple hours trying to implement it.
In my app, I am saving view properties (number of sub views etc) to an sqlite3 database.
While reading the data back, I though ‘Would it not be so much easier to just store the view in the database?’
So, using something like a blob type do you think it would be possible?
Something like:
- Bind blob to insert
view = sqlite3_column_blob(statement, 0);to retrieve
Does this sound like it could work? My biggest concern is knowing the size of the view on insert and select. Is something like this possible or is it not documented because it is too ridiculous?
Thanks!
and then getting it out
UIViewconforms toNSCoding, which means you can serialize and deserialize it. This is exactly how nib files work. First, see the Archives and Serializations Programming Guide.One easy way to serialize a
UIViewis like this:You can then write out
datain whatever way is convenient.To deserialize the view, use this:
This will make a new copy of the entire view hierarchy.
Note that
UIViewonly serializes its own properties. If you subclassUIViewand want to serialize additional properties, you will need to overrideencodeWithCoder:andinitWithCoder:to add your properties. This is detailed in Encoding and Decoding Objects.