预期的方法体

时间:2014-12-21 00:58:25

标签: objective-c xcode

  *.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

我如何宣布" - (double)yearsOfEmploymentsince"因为它是在另一个文件中声明但仍保持&#34 ;-(void)applicationDidFinishLaunching :( NSNotification *)aNotification {"作为主标题???

1 个答案:

答案 0 :(得分:2)

你的问题有点不清楚,特别是没有你的.h文件,看看这个类是什么的子类,但是这一行:- (double)yearsOfEmployment需要一个开头{,这就是& #34;预期的方法体"问题