Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8285849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:33:58+00:00 2026-06-08T11:33:58+00:00

I have an NSMutableArray containing the coordinates and sizes of multiple CGRects. I want

  • 0

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?

UPDATE:

This one is the data I retrieved from the database:

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

It is exactly the same as the one before I put inside the database.

The Code:

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:

    NSData *toData = [NSKeyedArchiver archivedDataWithRootObject:rectsArray];
    NSLog(@"The data %@", toData);
    NSArray *fromData = [NSKeyedUnarchiver unarchiveObjectWithData:toData];
    NSLog(@"The data %@", fromData);

The toData shows the archived form, but the fromData shows nothing at all. Why is this happening?

Here is a sample of rectsArray:

(
"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}}"
)

As you can see, it is an array of CGRects.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:33:59+00:00Added an answer on June 8, 2026 at 11:33 am

    Ok–this is a bit easier with Core Data, but the basics are the same. You need to store the array data into an NSData object using an archive:

    NSData *dataFromArray = [NSKeyedArchiver archivedDataWithRootObject:myArray];
    

    And then save that data as a blob in the database. Depending on the SQLite wrapper you use, it may have a method taking the NSData object and translating it into bytes for you, otherwise you can get the raw bytes with:

    const char *arrayBytes = [dataFromArray bytes];
    

    To get the data back out, you get the bytes from the database back into an NSData object and then unarchive it. Assuming that you can get your blob out of the database and into an NSData object called dataFromDB, you will do:

    NSArray *myArrayFromDB = [NSKeyedUnarchiver unarchiveObjectWithData:dataFromDB];
    

    And you’ll have your array back!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NSMutableArray in my class containing Ingredient objects. I want to check
hello I have a NSMutableArray iconlocarr . I also have another array containing dictionary
I have a Singleton which has an NSMutableArray containing a Class, the Class contains
I have an NSMutableArray of names. I want the pass the data (selected name)
I have a NSMutableArray and it has the users high scores saved into it.
I have an NSMutableArray which has five objects in it. I want to insert
I have a NSMutableArray called putNumberUsed. It contains the following objects @blah1,@blah2,@blah3,@blah4. I want
I'm currently dynamically creating UIButton objects in my view. I have an NSMutableArray containing
I have an ivar, keys which is an NSMutableArray containing 50 strings. When my
I have create a array containg person firstname,lastmane and number. Now i want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.