Q: Logic/iOS - Override certain values depending on if user entered or not I am looking for a way to properly perform the following. 
I have multiple values in an object that are given default values (some a physical number, other calculated). The user selects a few parameters and the rest are populated for them.
After the values are populated the user can then overwrite any value of their choosing which then may cause values to be re-calculated. If the value is a calculated value that the user has entered I don't want it to change.
Take for example the following:
Class values {
    NSString *userSelected:
    double value1;
    double value2;
    double value3;
    double calc1;
    double calc2;
    double calc3;
}

The user then selects (From a picker) values.userSelected. Upon selection, values 1 - 3 and calc 1 - 3 are assigned/calculated to their "default values".
The user can then go in and edit say value1. Once changed calc1-3 will re-calculate if they use value1. Now the user can also overwrite the calc values. So if the user overrides calc1 and then changes value1 I DO NOT want calc1 to change again since it was changed by the user. 
One way I thought to do this was duplicate each value with a default and if the non-default is set return that instead:
ie
Class values {
     double value1;
     double defaultValue1; ... etc.
}

Hence if the non-default value is set then use that, else use the default value. This just seems like an inefficient way of doing it. Does anyone have a better thought process on how to do this. My class is around 20 properties so I'd rather not require 2 properties per variable. I am programming in iOS but this is more a methodology question vs a specific piece of code. If anything is unclear please feel free to ask.
Thanks,
DMan

A: One thing that could do what you're looking for: accessor overrides. Basically, you declare in your class a bunch of values using @property syntax, then do some stuff under the hood in the implementation, including overriding the getter/setters. For example:
//in MyClass.h
@interface MyClass : NSObject

@property (nonatomic, assign) double value1;
@property (nonatomic, assign) double calc1;

@end

//in MyClass.m
@implementation MyClass {
    BOOL _calc1Changed;
}

//you should default that flag to NO, so...
- (id)init {
    _calc1Changed = NO;
}

- (void)setValue1:(double)newValue1 {
    if (!_calc1Changed) [self calculateCalc1]; //define this calculation also in this file
    value1 = newValue1; //value1 is the synthesized ivar for the property you declared
}

And of course, somewhere you'll need to call _calc1Changed = YES; whenever the user sets calc1 manually, possibly in a similarly constructed override. Basically, the result is that every time you call myClassInstance.value1 = something or [myClassInstance setValue1:something] these checks will be performed and extra functionality can be performed to validate/respond to inputs.
