Please help me I think Im blind


#1

Im working on the Chapter 19 Challenge but I have and error which for the life of me I can’t find. Can anyone see it?
I get a warning message that states implementation incomplete in my Portfolio.m file, and I think its the root of my error.

Portfolio.h

#import <Foundation/Foundation.h>

@interface Portfolio : NSObject
{
    NSMutableArray *foreignStocks;
    NSMutableArray *domesticStocks;
}

- (void)addForeignStock;  // add a foreign stock to the array
- (void)addDomesticStock; // add a Domestic stock to the array
- (float)currentValue;    // returns the total value of a portfolio instance

@end

Portfolio.m this is where I get the warning

[code]#import “Portfolio.h”
#import “ForeignStockHolding.h”
#import “StockHolding.h”

@implementation Portfolio

  • (void)addForeignStock:(ForeignStockHolding *)FStock
    {
    if (!foreignStocks) {
    foreignStocks = [[NSMutableArray alloc] init];
    }
    [foreignStocks addObject:FStock];
    }

  • (void)addDomesticStock:(StockHolding *)DStock
    {
    if (!domesticStocks) {
    domesticStocks = [[NSMutableArray alloc] init];
    }
    [domesticStocks addObject:DStock];
    }

  • (float)currentValue
    {
    float tally = 0.0;
    for (int i = 0; i < [foreignStocks count]; i++) {
    tally += [[foreignStocks objectAtIndex:i] valueInDollars];
    }
    for (int i = 0; i < [domesticStocks count]; i++) {
    tally += [[domesticStocks objectAtIndex:i] valueInDollars];
    }
    return tally;
    }

@end
[/code]

Any help is greatly appreciated


#2

The method declarations are missing their arguments.

Turn off the Autopilot and fly in manual mode.


#3

OMG !!!

I’ve been puzzling over this for hours! Yes I see it now!

I think I understand where I went so wrong in finding this problem for myself.
When I was doing comparisons between my .h and .m files I was doing them solely with in this project. That is a problem, because my other classes do not have parameters passed in them so naturally their header files (.h files) don’t have the parameter portion of the declarations for their methods.

I should have drawn my comparisons with other classes from other projects which contain methods that similarly use parameters in them such as the modified BMITime project from the same chapter (chapter 19). More specifically on page 120 (I keep getting jinks by this page), had I look more carefully at Employee.m and Employee.h at method addAssetsObject and compared it to how I was declaring my method I would have seen right away that I was missing the parameter portion in my Portfolio.h file for both method declarations.

Thank You soooooo Much ibex10 for finding this for me, I was beginning to think there was a bug in Xcode, or that I was going blind.
I completed the challenge and have posted under a new topic “Solution to Challenge by Roggy67”, incase others want to compare, or maybe discover more problems or unconventional uses of syntax with it. For example I used the #define directive to make a random macro which I use to generate interesting values.