I am running Xcode 9.0.
When I use this line of code in Chapter 21
(NSString *)description
I get an error message telling me "Use of undeclared identifier ‘description’"
I cannot figure out what this error message is telling me or how to fix it…
Thanks for the help!
(void)addAsset:(BNRAsset *)a
{
//Is asset nil?
if (!_assets) {
//Create the array
_assets = [[NSMutableArray alloc]init];
}
[_assets addObject:a];
}
(unsigned int)valueOfAssets
{
//Sum up the resale value of the assets
unsigned int sum = 0;
for (BNRAsset *a in _assets){
sum += [a resaleValue];
}
return sum;
}
(double)yearsOfEmployment
{
//Do I have a non-nil hire date?
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;
}
}
This is causing the compiler to include the new function (NSString *)description… as part of the bodyMasIndex function declaration and it doesn’t know what to do with it.
As an aside, the code posted is still in a state of jumble because instead of a pair of three back-tick characters (```), a pair of two back-slash characters (\\) were used.
When you ask for help next time, please place your code between a pair of three back-tick characters like this:
```
Place code here… ```
If you are using an Apple keyboard, you will find the back-tick character (`) on the same key for the tilde character (~).
Finally, coding requires paying undivided attention to details, no matter how tiny they are.