2014-12-21 20 views
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 {」作爲主標題???預期的方法體

回答

2

你的問題有點不清楚,特別是沒有你的.h文件來查看這個類是什麼類的,但是這一行:- (double)yearsOfEmployment需要一個開口{,這是「期望的方法體」問題。

+0

.h文件現在包含在內 – Kevin

+0

@Kevin,@RobP指的是爲方法實現打開大括號(大括號)。而不是' - (double)yearsOfEmployment',你需要有' - (double)yearsOfEmployment {'。注意'''。 –

+0

這是我第一次嘗試修復它,但現在我收到他編譯器錯誤「使用未聲明的標識符'ApplicationDidFinishLaunching'」 – Kevin