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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:37:41+00:00 2026-05-25T14:37:41+00:00

I have following situation in my project (in which I use Core Data): I

  • 0

I have following situation in my project (in which I use Core Data): I have an entity which has two BOOL properties: isCompleted and isNonVisit. It also has third property: NSNumber *status – the value of the property depends on both isCompleted and isNonVisit values.

When either of the BOOL property changes, I want status property to be actualised automatically.

All three properties must be present in underlying database, since I use fetchedResultsController that makes use of status property (as sort descriptor and as sectionNameKeyPath).

I came up with following solution:

in .h file:

@property (nonatomic, retain) NSNumber *isCompleted;
@property (nonatomic, retain) NSNumber *isNonVisit;
@property (nonatomic, retain) NSNumber *status;

- (NSNumber *)calculateStatus;  //Returns proper status value based on isCompleted and nonVisit property values.

in .m file:

@dynamic isCompleted;
@dynamic isNonVisit;
@dynamic status;

- (void)setIsCompleted:(NSNumber *)newValue
{
  [self willChangeValueForKey:@"isCompleted"];
  [self setPrimitiveValue:newValue forKey:@"isCompleted"];
  [self didChangeValueForKey:@"isCompleted"];

  self.status = [self calculateStatus];
}


- (void)setIsNonVisit:(NSNumber *)newValue
{
  [self willChangeValueForKey:@"isNonVisit"];
  [self setPrimitiveValue:newValue forKey:@"isNonVisit"];
  [self didChangeValueForKey:@"isNonVisit"];

  self.status = [self calculateStatus];
}

The solution seems to work.

So, my question is: Is it OK? Am I violating some rules of CoreData or KVO?

Thanks for any suggestions.

  • 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-05-25T14:37:42+00:00Added an answer on May 25, 2026 at 2:37 pm

    Your method seems sound.

    The only suggestion I would have is to reduce the redundancy by extracting the boolean information from the status with accessor methods rather than storing them. You still should be able to use the desired predicates for your fetch requests just using the status variable. But the overhead of storing this extra information should be minimal.

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

Sidebar

Related Questions

I have a following situation in my project. There are some tag values which
Consider the following situation: I have two android projects named P1 and P2 which
I have the following situation. My project has a main.scala.html file and a folder
I have the following situation: A project MyCompany.MyProject.Domain which contains my domain model, and
I must have done something very stupid which has caused the following situation. Basically
I have the following situation Project A - Uses Castle Windsor v2.2 - Uses
This is not a ruby/rails project deploy. I have the following situation and I
I have following situation: I have a Maven war project in NetBeans 6.7 I
I have a problem with JPA 1.0 (OpenJPA) Following situation @Entity public class A{
I have the following situation I have one swt class which displays a simple

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.