NSLog, using [person <method name>] & use of {} in header


#1

Hello-

I was wondering in this code why its necessary to use the following local variable

[code]float bmi = [person bodyMassIndex];
NSLog(@“Employee ID: %@ has a BMI of %f”, [person employeeID], bmi);

[/code]

and instead use [person bodyMassIndex] in place of bmi in the NSLog statement, like so…


NSLog(@"Employee ID: %@ has a BMI of %f", [person employeeID], [person bodyMassIndex]);

Is the first method a better practice?

Second Question

Is it necessary to enclose the variable in brackets as in the book like here

//
//  Employee.h
//  BMITime
//
//  Created by Joseph Long on 7/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Person.h"

@interface Employee : Person
{
    int employeeID;
}

@property int employeeID;

@end

could you just do this?

//
//  Employee.h
//  BMITime
//
//  Created by Joseph Long on 7/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Person.h"

@interface Employee : Person


@property int employeeID;

@end

thanks
Joseph