.m文件目標C的Xcode頭部差錯
#import "BNREmployee.h"
@interface BNREmployee()
@property (weak) IBOutlet NSWindow *window;
@end
@implementation BNREmployee
- (double)yearsOfEmployment {
**Use of undeclared identifier 'applicationDidFinishLaunching'** -(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;
}
}
- (float) bodyMassIndex
{
float normalBMI = [super bodyMassIndex];
return normalBMI * 0.9;
}
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}
@end
h文件
#import "BNRPerson.h"
@interface BNREmployee : BNRPerson
@property (nonatomic) unsigned int employeeID;
@property (nonatomic) unsigned int officeAlarmCode;
@property (nonatomic) NSDate *hireDate;
- (double)yearsOfEmployment;
@end
我被提示在另一個答案後使用{ - (雙)yearsOfEmployment但線路是另一個後其中變量'applicationDidFinishLaunching'沒有在其他地方聲明,因爲它是已經在Xcode中實現的通用變量。這就是爲什麼我想知道如何讓我的語法正確,以避免編譯器錯誤。
看起來你很長時間沒編程。在開始編程之前,您應該瞭解一種語言的語法。像這裏一樣在網上獲得一些教程https://www.thenewboston.com/videos.php?cat=33 –
如果您可以解決您的問題以關閉此帖,請標記正確的答案。 –