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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:54:12+00:00 2026-05-21T15:54:12+00:00

In my project, which is written entirely with Core Data and bindings, I have

  • 0

In my project, which is written entirely with Core Data and bindings, I have two text fields which contain float values. I want to make a third text field that is the first field divided by the second. What is the best way to go about this using Core Data? Should I make a custom accessor for the third field?

  • 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-21T15:54:12+00:00Added an answer on May 21, 2026 at 3:54 pm

    Make a method -thirdValue in your NSManagedObject subclass that does the calculation:

    - (CGFloat)thirdValue
    {
      return value1 / value2; // should probably do a value2 != 0 check
    }
    

    and then +keyPathsForValuesAffectingValueForKey for the class:

    + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key
    {   
        NSSet *superSet = [super keyPathsForValuesAffectingValueForKey:key];
    
        if ([key isEqualToString:@"thirdValue"])
            return [[NSMutableSet setWithObjects:@"value1", @"value2", nil] unionSet:superSet];
    
        return superSet;
    }
    

    this sets up thirdValue to be dependent on value1 and value2. Whenever value1 or value2 change, there will also be a KVO notification for thirdValue. So if you have a field that binds to it, the field will display the new calculated value. It’s a a handy trick when you need to display a key who’s value is dependent on other keys.

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

Sidebar

Related Questions

I have written a Flex Library project - a .swc file - which is
I have a project which it's domain contain following classes: Courier Customer Food Order
I have a large project which was originally written in C#1.1 and is now
I have a project which has several custom descriptors written for the assembly plugin.
I have a legacy project which has all the source files, templates, properties written
I have been working on a project which is about data copy from one
I have recently developed a project which is written using Symfony 1.4 which I
If i have a project which has a text file inside of it and
I have the source code for a C# project (which wasn't written by me)
I have written a JPA-Project which encapsulates all my entities. Since these entities are

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.