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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:21:35+00:00 2026-06-11T19:21:35+00:00

I have an entity called Color that has R,G,B stored, and a subclass that

  • 0

I have an entity called “Color” that has R,G,B stored, and a subclass that returns saturation, UIColor, etc., as needed. I recently wrote some code where I needed the Color entity to be the Class “Color” so I could call a method on it.

But it seems that broke another part.

Before I store the colors, I use the Color class to figure out what colors to store, based on the methods in the Color class. This is where I’m running into problems.

Color *color = [[Color alloc] initWithColor:[UIColor whiteColor]];
if (color.saturation > 0.2) {
    [self addOrIncrementColor:color];
}

At the if statement, the debugger shows:

color   Color * 0x1f532740
NSManagedObject NSManagedObject 
red CGFloat 0.392157
green   CGFloat 0.443137
blue    CGFloat 0.203922
count   __NSCFNumber *  0x1f559d00
color   UIDeviceRGBColor *  0x200e8f10
saturation  CGFloat 0.539823

However, if I print the description of the Color object, I get:

Color: 0x1f532740 (entity: (null); id: (null) ; data: {})

This of course, passes the color object to the addOrIncrement: method with null info, even though it is set locally.

Any idea how I can get this to work?

  • 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-11T19:21:36+00:00Added an answer on June 11, 2026 at 7:21 pm

    It doesn’t look normal to be using NSManagedObjects like you would for normal objects (e.g. with the usual alloc init. Instead, NSManagedObjects should be created with the NSManagedObjectContext.

    That being said, if you just want a temporary NSManagedObject that will not be saved to a context, then create them as you would normally, but with a nil context:

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Color" inManagedObjectContext:managedObjectContext];
    Color *color = [[Color alloc] initWithEntity:entity insertIntoManagedObjectContext:nil];
    if (color.saturation > 0.2) {
        ...
    }
    

    Check out this other post for reference.

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

Sidebar

Related Questions

Say I have an entity called Request that has collections of child entities like
I have an entity called guestlist that has a 1 to many relationship to
I have an Google App Engine entity called MyFile. It has properties such as
I have an Entity called Keyword, and it has two rows: id comment_id foo_id
I have an entity called Photo. A photo has a date field and I
I'm building an Asp.net MVC 2 application. I have an entity called Team that
I have an entity called 'SyncInfo' (including a UUID and a modified date) that
So I have An entity called VideoAsset that is mapped to a VideoCategory and
I have an entity called PendingPartners which has a navigation property to the Residents
Let's say I have an entity called EntityA . EntityA has a relationship 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.