Kevin
Kevin

Reputation: 45

Expected method body

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

How can i declare "- (double)yearsOfEmploymentsince" since it is declared in another file but while still keeping the "-(void)applicationDidFinishLaunching:(NSNotification *)aNotification {" as the main header???

Upvotes: 0

Views: 1904

Answers (1)

RobP
RobP

Reputation: 9542

Your question is a little unclear especially without your .h file to see what this class is a subclass of, but this line: - (double)yearsOfEmployment needs an opening {, that's the "expected method body" problem.

Upvotes: 2

Related Questions