0
*.m file*
#import "BNREmployee.h"
@interface BNREmployee()
@property (weak) IBOutlet NSWindow *window;
@end
@implementation BNREmployee
- (double)yearsOfEmployment
// **Error expected method body**-(void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Do I have a non-nil hireDate?
if (self.hireDate) {
// NSTimeInterval is the same as double
NSDate *now = [NSDate date];
NSTimeInterval secs = [now timeIntervalSinceDate:self.hireDate];
return secs/31557600.0; // Seconds per year
} else {
return 0;
}
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}
@end
*.h file*
#import "BNRPerson.h"
@interface BNREmployee : BNRPerson
@property (nonatomic) unsigned int employeeID;
@property (nonatomic) unsigned int officeAlarmCode;
@property (nonatomic) NSDate *hireDate;
- (double)yearsOfEmployment;
@end
我怎樣才能申報「 - (雙)yearsOfEmploymentsince」,因爲它是在另一個文件中聲明,但同時仍保持「 - (空)的applicationDidFinishLaunching:(NSNotification *)aNotification {」作爲主標題???預期的方法體
.h文件現在包含在內 – Kevin
@Kevin,@RobP指的是爲方法實現打開大括號(大括號)。而不是' - (double)yearsOfEmployment',你需要有' - (double)yearsOfEmployment {'。注意'''。 –
這是我第一次嘗試修復它,但現在我收到他編譯器錯誤「使用未聲明的標識符'ApplicationDidFinishLaunching'」 – Kevin