Diese Klasse ist nicht mit der Schlüsselwertcodierung für den Schlüssel XXX kompatibel

Ich bin ein Anfänger in allem Programmieren und habe versucht, selbst erlerntes Material aus den Big Nerd Ranch Books zu implementieren. Aber ich bin wirklich ratlos von diesem Problem, und ja, ich habe in diesem und anderen Foren nach möglichen Lösungen gesucht, ohne Erfolg. Hier ist der Code:

ANKYViewController.h:

#import <UIKit/UIKit.h>

@interface ANKYViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *weightFieldDeadlift;
@property (weak, nonatomic) IBOutlet UITextField *repFieldDeadlift;
@property (strong, nonatomic) IBOutlet UILabel *workingOneRMDeadlift;

@property (weak, nonatomic) IBOutlet UITextField *weightFieldBenchPress;
@property (weak, nonatomic) IBOutlet UITextField *repFieldBenchPress;
@property (strong, nonatomic) IBOutlet UILabel *workingOneRMBenchPress;

@property (weak, nonatomic) IBOutlet UITextField *weightFieldSquat;
@property (weak, nonatomic) IBOutlet UITextField *repFieldSquat;
@property (strong, nonatomic) IBOutlet UILabel *workingOneRMSquat;

@property (weak, nonatomic) IBOutlet UITextField *weightFieldMilitaryPress;
@property (weak, nonatomic) IBOutlet UITextField *repFieldMilitaryPress;
@property (strong, nonatomic) IBOutlet UILabel *workingOneRMMilitaryPress;

- (IBAction)calculateOneRM:(id)sender;

@end

ANKYViewController.m:

#import "ANKYViewController.h"

@interface ANKYViewController ()

@end

@implementation ANKYViewController
@synthesize weightFieldDeadlift;
@synthesize repFieldBenchPress;
@synthesize workingOneRMBenchPress;
@synthesize weightFieldSquat;
@synthesize repFieldSquat;
@synthesize workingOneRMSquat;
@synthesize weightFieldMilitaryPress;
@synthesize repFieldMilitaryPress;
@synthesize workingOneRMMilitaryPress;
@synthesize repFieldDeadlift;
@synthesize workingOneRMDeadlift;
@synthesize weightFieldBenchPress;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [self setWeightFieldDeadlift:nil];
    [self setRepFieldDeadlift:nil];
    [self setWorkingOneRMDeadlift:nil];
    [self setWeightFieldDeadlift:nil];
    [self setRepFieldBenchPress:nil];
    [self setWeightFieldBenchPress:nil];
    [self setWorkingOneRMBenchPress:nil];
    [self setWeightFieldSquat:nil];
    [self setRepFieldSquat:nil];
    [self setWorkingOneRMSquat:nil];
    [self setWeightFieldMilitaryPress:nil];
    [self setRepFieldMilitaryPress:nil];
    [self setWorkingOneRMMilitaryPress:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)calculateOneRM:(id)sender {
    float dw = [[weightFieldDeadlift text]floatValue];
    float dr = [[repFieldDeadlift text]floatValue];
    float d = (dw * dr * 0.0333) + dw;
    NSLog(@"Deadlift: %f", d);
    NSString *deadlift = [[NSString alloc]initWithFormat:@"%f", d];
    [workingOneRMDeadlift setText:deadlift];

    float bpw = [[weightFieldBenchPress text]floatValue];
    float bpr = [[repFieldBenchPress text]floatValue];
    float bp = (bpw * bpr * 0.0333) + bpw;
    NSLog(@"Bench Press: %f", bp);
    NSString *benchPress = [[NSString alloc]initWithFormat:@"%f", bp];
    [workingOneRMBenchPress setText:benchPress];

    float sw = [[weightFieldSquat text]floatValue];
    float sr = [[repFieldSquat text]floatValue];
    float s = (sw * sr * 0.0333) + sw;
    NSLog(@"Squat: %f", s);
    NSString *squat = [[NSString alloc]initWithFormat:@"%f", s];
    [workingOneRMSquat setText:squat];

    float mpw = [[weightFieldMilitaryPress text]floatValue];
    float mpr = [[repFieldMilitaryPress text]floatValue];
    float mp = (mpw * mpr * 0.0333) + mpw;
    NSLog(@"Military Press: %f", mp);
    NSString *militaryPress = [[NSString alloc]initWithFormat:@"%f", mp];
    [workingOneRMMilitaryPress setText:militaryPress];
}
@end

Die Eigentümerklasse der Datei ist bereits als ANKYViewController angegeben. Das Verknüpfen der Steckdosen usw. erfolgte durch Ziehen, anstatt manuell zu codieren (ich gab auf, nachdem ich zu viele Stunden damit verbracht hatte).

Der Fehler:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x6c22e70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key repsField.'

Es wird kein Code kopiert und eingefügt, und es ist sicherlich bedauerlich, dass "repsField" (anstelle von repFieldxxx) nirgendwo erwähnt wird.

Ich hoffe, dass dies genug Informationen sind, um zu einer Lösung zu führen, da ich tagelang erfolglos nach Lösungen anderer Leute gesucht habe.

Vielen Dank.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage