Код, вероятно, лучший способ увидеть, что я пытаюсь сделать:
AcInfo.h:
@interface AcInfo : NSManagedObject {
@private
}
@property (nonatomic, retain) NSString *registrationNumber;
@end
AcInfo.m:
@implementation AcInfo
@dynamic registrationNumber;
@end
AnotherClass.h:
@interface AnotherClass : NSObject {
}
@property (nonatomic, retain) AcInfo *detailItem;
@property (nonatomic, retain) IBOutlet UITextField *registrationNumberTextField;
- (void)setDetailItemValueFromUIElement:(id *)uiElement forAcInfoTarget:(id *)acInfoTarget;
@end
AnotherClass.m:
@import "AcInfo.h"
@implementation AnotherClass
@synthesize detailItem, registrationNumberTextField;
- (void)viewDidLoad
{
[super viewDidLoad];
registrationNumberTextField.text = @"Test";
// I expect this to set detailItem.registrationNumber to the value of
// registrationNumberTextField.text (Test) but it doesn't change anything!
setDetailItemValueFromUIElement:registrationNumberTextField forAcInfoTarget:detailItem.registrationNumber;
}
- (void)setDetailItemValueFromUIElement:(id *)uiElement forAcInfoTarget:(id *)acInfoTarget
{
if ([(id)uiElement isKindOfClass:[UITextField class]]) {
// This doesn't do anything when it returns!
(NSString *)acInfoTarget = (UITextField *)uiElement.text
return;
}
}
@end
Короче говоря, я хочу, чтобы acInfoTarget
вызвал метод получения [detailObject registrationNumber]
и метод установки [detailObject setRegistrationNumber]
setDetailItemValueFromUIElement:
функция ...