programming with objective-c exercise designated initializer

From my previous post, this is what I have so far in completing Exercise 2 to declare and implement a designated initializer. What am I doing wrong and how do I fix them?


- (id)initFirstName:(NSString *)firstNameValue initLastName:(NSString *)lastNameValue initDateOfBirth:(NSDate *)dateOfBirthValue {


[super init];

_firstName = firstNameValue;

_lastName = lastNameValue;


}


I'm getting an error that says "Expected method body" on the first line. On the line that assigns a value to _firstName I get an two errors, (1) "Use of undeclared identifier 'firstNameValue'", (2) "Instance variable '_firstName' accessed in class method".


I had declared the following properties and method in the .h file.


@property NSString *firstName;

@property NSString *lastName;

@property NSDate *dateOfBirth;


- (id)initFirstName:(NSString *)firstNameValue initLastName:(NSString *)lastNameValue initDateOfBirth:(NSDate *)dateOfBirthValue;

The code you showed is valid. I suspect the problem is in code before what you're showing here. For example, you didn't terminate a previous method, or you had a method declaration (not definition) with no semi-colon.


There are issues with the content of your initializer, but they would not have causes the compiler error you're seeing. I'll leave those be for the time being until you're past the compiler error.

I responded on your other thread.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

WWDC runs Mon, 13 Jun through to Fri, 17 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face. http://developer.apple.com/wwdc/

programming with objective-c exercise designated initializer
 
 
Q