Amazon.com Widgets 'Incomplete implementation of class ... 'warning question
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 01, 2014, 05:23:20 PM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Program Examples
| | |-+ Chapter 6
| | | |-+ 'Incomplete implementation of class ... 'warning question
Pages: [1] Go Down
Print
Author Topic: 'Incomplete implementation of class ... 'warning question (Read 1868 times)
Phillip Anthony
Newbie
*
Posts: 37


Email




on: April 28, 2010, 05:57:16 PM

I recently typed in example 6.8 and at the end of the @implementation section, on the @end line I keep getting the following warning:

Incomplete implementation of the class 'Calculator'.

What I have is:

@implementation Calculator

...
method definitions
...

@end

To the best of my knowledge this correct.  But I'm thinking that the cause of this error may not lie in this section of code at all.  I went so far as to // out @end and the error went away and the program compiled without any problem.  I understand that this is a warning and not an actual error which would halt compilation. 

This is not the first time that I have seen this warning and would like to have some idea why this occurs.

Thanks,
Phillip

Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #1 on: April 28, 2010, 06:14:35 PM

The warning message indicates you haven't included all the methods in your implementation section that you declared in your interface section.

Cheers,

Steve Kochan
Last Edit: April 28, 2010, 06:27:11 PM by skochan Logged
Phillip Anthony
Newbie
*
Posts: 37


Email




Reply #2 on: April 29, 2010, 03:47:54 AM

Thanks, Steve, but that is not the case in this instance.  Out of sheer laziness, I have a habit of copying and pasting all of the declared methods from the @interface section into the @implementation section and then expanding them.

My one thought is this: Were you thinking that I was not using a Foundation Tool for this particular example? 

I ask because if I had built this onto a Cocoa app template with separate ...h and ...m files then this may indeed be the case if I failed to include a declared method in the @implementation section of the ...m file.

This issue is not a train-stopper, just a minor irritant.

I appreciate your help,
Phillip
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #3 on: April 29, 2010, 04:28:05 AM

Post your interface and implementations sections and I'll have a look.

Cheers,

Steve
Logged
Phillip Anthony
Newbie
*
Posts: 37


Email




Reply #4 on: April 29, 2010, 04:36:17 AM

Steve,

Here you go.  Thanks for taking a look at this.

After pasting in the code I noticed that the yellow warning did not copy/paste but I left a //****** ... denoting where the warning was.

Thanks again,
Phillip
======================

#import <Foundation/Foundation.h>

@interface Calculator : NSObject
{
   double accumulator;
}

// accumulator methods
-(void) setAccumlator : (double) value;
-(void) clear;
-(double) accumulator;

// arithmetic methods
-(void) add         : (double) value;
-(void) subtract   : (double) value;
-(void) multiply   : (double) value;
-(void) divide      : (double) value;

@end // end of interface section

@implementation Calculator

-(void) setAccumulator : (double) value
{
   accumulator = value;
}

-(void) clear
{
   accumulator = 0;
}

-(double) accumulator
{
   return accumulator;
}

-(void) add      : (double) value
{
   accumulator += value;
}

-(void) subtract : (double) value
{
   accumulator -= value;
}

-(void) multiply : (double) value
{
   accumulator *= value;
}

-(void) divide   : (double) value
{
   accumulator /= value;
}

@end // *********************************************THIS IS WHERE THE WARNING LINE WAS

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   double value_1, value_2;
   char operator;
   
   Calculator *deskCalc;
   deskCalc = [[ Calculator alloc ] init ];
   
   NSLog (@" Type in your expression as number operator number ");
   scanf ( "%lf %c %lf", &value_1, &operator, &value_2 );
   
   [ deskCalc setAccumulator : value_1 ];
   
   if ( operator == '+' )
      [ deskCalc add : value_2 ];
   
   else if ( operator == '-' )
      [ deskCalc subtract : value_2 ];
   
   else if ( operator == '*' )
      [ deskCalc multiply: value_2 ];
   
   else if ( operator == '/' )
      [ deskCalc divide : value_2 ];
      
   NSLog (@" %.2f", [ deskCalc accumulator ] );
   
   [ deskCalc release ];   
   
    [pool drain];
    return 0;
}
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #5 on: April 29, 2010, 11:18:08 AM

You have a typo in your interface section:

Code: (Objective-C)
-(void) setAccumlator : (double) value;

The compiler never finds a method with that spelling defined in the implementation section, thus the reason for the warning message.

Cheers,

Steve Kochan
Logged
Phillip Anthony
Newbie
*
Posts: 37


Email




Reply #6 on: April 29, 2010, 11:29:07 AM

Got it, Steve! 

I'm amazed that the code even compiled and gave correct results since I don't think the accumulator (correct spelling this time) ever got set.

Sorry for the bother.  Spelling is an inexcusable mistake to make when coding.

My sincerest thanks to you for spotting this dumb mistake. 

Regards,
Phillip
Logged
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.