Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring NSMutableArray in Sqlite
    text
    copied!<p>I have an NSMutableArray containing the coordinates and sizes of multiple CGRects. I want to store this into the sqlite. Is it possible to store the whole array? Or should I just store the CGRects manually in the database?</p> <p><strong>UPDATE:</strong></p> <p>This one is the data I retrieved from the database:</p> <pre><code>62706c69 73743030 d4010203 04050817 18542474 6f705824 6f626a65 63747358 24766572 73696f6e 59246172 63686976 6572d106 0754726f 6f748001 a3090a0f 55246e75 6c6cd20b 0c0d0e5a 4e532e6f 626a6563 74735624 636c6173 73a08002 d2101112 16582463 6c617373 65735a24 636c6173 736e616d 65a31314 155e4e53 4d757461 626c6541 72726179 574e5341 72726179 584e534f 626a6563 745e4e53 4d757461 626c6541 72726179 12000186 a05f100f 4e534b65 79656441 72636869 76657208 11161f28 32353a3c 40464b56 5d5e6065 6e797d8c 949dacb1 00000000 00000101 00000000 00000019 00000000 00000000 00000000 000000c3 </code></pre> <p>It is exactly the same as the one <em>before</em> I put inside the database. </p> <p>The Code:</p> <p>This is the code I am using to check if the NSArray is being archived. I am not putting it in a database yet, because I just want to make sure that the NSKeyedUnarchive works. Here it is:</p> <pre><code> NSData *toData = [NSKeyedArchiver archivedDataWithRootObject:rectsArray]; NSLog(@"The data %@", toData); NSArray *fromData = [NSKeyedUnarchiver unarchiveObjectWithData:toData]; NSLog(@"The data %@", fromData); </code></pre> <p>The <code>toData</code> shows the archived form, but the <code>fromData</code> shows nothing at all. Why is this happening?</p> <p>Here is a sample of <code>rectsArray</code>:</p> <pre><code>( "NSRect: {{83.389008, 179.61432}, {8.775116, -10.616217}}", "NSRect: {{83.389008, 179.61432}, {8.775116, -10.616217}}", "NSRect: {{83.389008, 179.61432}, {8.775116, -10.616217}}", "NSRect: {{96.085426, 179.61432}, {5.2029028, -10.616217}}", "NSRect: {{101.28833, 179.61432}, {5.8532658, -10.616217}}", "NSRect: {{107.1416, 179.61432}, {4.5525398, -10.616217}}", "NSRect: {{115.61544, 179.61432}, {3.2518141, -10.616217}}", "NSRect: {{115.61544, 179.61432}, {3.2518141, -10.616217}}", "NSRect: {{118.86726, 179.61432}, {6.5036283, -10.616217}}", "NSRect: {{118.86726, 179.61432}, {6.5036283, -10.616217}}" ) </code></pre> <p>As you can see, it is an array of CGRects.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload