Issue: I have a standard subclassed NSManagedObject (see below). I have a view controller I'd like to use to edit all of the NSString* 's of the NSManagedObject. I only want to pass a reference to the pointer of any of the NSString* 's below to edit. How can do I do this? Is there a better way to setup editing screens and references? Right now I'm passing the entire NSManagedObject * to the editing ViewController, then do a hack job of using an integer to update/edit the correct property I want to edit from the NSManagedObject.
Is there a more elegant way of doing this? I've yet to see a nice clean example of working with editing entities from core data and am relatively new to interface design.
NSManagedObject:
@inter开发者_JAVA技巧face MySounds : NSManagedObject {
}
@property (nonatomic, retain) NSString * soundOne;
@property (nonatomic, retain) NSString * soundTwo;
@property (nonatomic, retain) NSString * soundThree;
The Edit Interface:
@interface EditItemViewController : UIViewController
<UITextViewDelegate>
{
MySounds *sounds;
int fieldToEdit;
...
}
@property (nonatomic, assign) MySounds *toSave;
@property (nonatomic) int fieldToEdit;
Example of how I use the int and MySounds *:
- (void) viewDidLoad
{
switch (fieldToEdit)
{
...
case 2:
{
[self.textField setText:[self.sounds soundOne]];
}
...
}
...
}
Ugh. Nevermind the entire question.
I forgot about key-value coding with nsmanagedobjects :)
精彩评论