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 8837557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:45:24+00:00 2026-06-14T09:45:24+00:00

What is the best practice for storing CoreGraphics struct based values such as CGRect

  • 0

What is the best practice for storing CoreGraphics struct based values such as CGRect, CGPoint, etc into proper objects for the purpose of storing in collection classes?

You can either use NSValue:

    NSMutableArray *values = [NSMutableArray array];

    CGRect rect = CGRectMake(0, 0, 100, 100);
    NSValue *value = [NSValue valueWithCGRect:rect];

    [values addObject:value];

    CGRect rectValue = [values[0] CGRectValue];

or NSString:

    NSMutableArray *values = [NSMutableArray array];

    CGRect rect = CGRectMake(0, 0, 100, 100);
    NSString *string = NSStringFromCGRect(rect);

    [values addObject:string];

    CGRect rectValue = CGRectFromString(string);

Just wondering if there was something I was missing and there was an advantage to one over the other.

  • 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-14T09:45:26+00:00Added an answer on June 14, 2026 at 9:45 am

    The first way is more “canonical” because it has smaller footprint in memory, and does not require much CPU to do the conversion. There is also no possibility of the precision loss due to conversion to decimal and back: the floats inside the structs are stored in their native format.

    To be fair, the differences between the two approaches are negligible, unless you need to deal with tens of thousands of objects.

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

Sidebar

Related Questions

Is there a best practice on how to hash an arbitrary string into a
Short best practice question: If an object A is injected into another object B,
What is the best practice when storing a directory in a file name on
I would like to define a best practice for storing timestamps in my Postgres
What's the best practice for storing a large amount of image data in SQL
What is best practice for storing large photos/text files in sql server. Baring the
I was hoping for some guidelines on the general best practice for storing data
What's the best practice for storing and referencing JS for admin section of site?
I am wondering what is the best practice when it comes to storing html
What is the best practice for storing keys, and or passwords for a website.

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.