Newbie help w/ Xcode Project

Discussion in 'iOS Programming' started by Heisler98, Mar 6, 2011.

  1. Heisler98 macrumors member

    Joined:
    Oct 30, 2010
    #1
    I'm a newbie to developing and could someone help me with warnings that keep popping up on a project? I'm using Lynda.com's iPhone SDK development tutorials and I built a small project and it executes fine, but it has warnings and I want to know exactly what they mean. Could someone help?

    It has 4 warnings with something about incomplete implementation in this class i made: Dog. :)

    Link here to the project folder: http://www.huntereisler.com/xcodeproj/CustomClass

    Much appreciated,
    Hunt
     
  2. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #2
    Posting the actual warnings would be helpful...
     
  3. Heisler98 thread starter macrumors member

    Joined:
    Oct 30, 2010
    #3
    Sorry:

    1st: 'Dog' may not respond to '-howl'
    (Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments.)

    2nd: 'Dog' may not respond to '-howl'. (Don't understand why this was listed twice, maybe cuz I had it in both the .h and the .m files?)

    3rd: Incomplete implementation of class 'Dog'
    4th: Method definition for '-Howl' not found


    I did the exact thing to recreate the object from what the Lynda.com guy said, and yet, I get warnings. Huh.

    Would I be rejected by Apple's App Store (if (1) this was an iPhone app and (2) it was much more sophisticated) if it had warnings?

    Thx.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    Code from the posted url:
    Code:
    @interface Dog : NSObject {
    	//ivars
    	int age;
    	NSString *name;
    }
    //public methods 
    - (void) bark;
    - (void) setName: (NSString *) n;
    - (void) Howl;
    
    Objective-C is case-sensitive. -Howl is not the same as -howl.

    Code:
    @implementation Dog
    - (void) bark {
    	NSLog(@"Woof, says %@", name);
    }
    
    - (void) setName: (NSString *) n {
    	name = n;
    }
    
    - (void) howl {
    	NSLog(@"HOWL, says %@", name);
    }
    
    You've implemented -howl, but haven't implemented -Howl.
     
  5. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #5
    it looks like the "why" was answered. It wouldn't be rejected, but your code is not going to work as you intend. In this case, you would get an error if you tried to call the howl method.
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    No, -howl works, because there is an actual implementation for -howl.

    A runtime error will occur if you tried to call -Howl, which is declared in Dog's @interface, but which has no implementation.

    Try it.
    Code:
    [B]gcc -framework Foundation Dog.m dogmain.m[/B]
    Dog.m:24: warning: incomplete implementation of class 'Dog'
    Dog.m:24: warning: method definition for '-Howl' not found
    dogmain.m: In function 'main':
    dogmain.m:19: warning: 'Dog' may not respond to '-howl'
    dogmain.m:19: warning: (Messages without a matching method signature
    dogmain.m:19: warning: will be assumed to return 'id' and accept
    dogmain.m:19: warning: '...' as arguments.)
    dogmain.m:20: warning: 'Dog' may not respond to '-howl'
    
    [B]./a.out[/B]
    2011-03-06 15:53:45.492 a.out[23665] Woof, says Fido
    2011-03-06 15:53:45.492 a.out[23665] Woof, says Lucky
    2011-03-06 15:53:45.492 a.out[23665] HOWL, says Lola
    2011-03-06 15:53:45.492 a.out[23665] HOWL, says Hank
    
    dogmain.m (from CustomClass.m of linked original)
    Code:
    #import <Foundation/Foundation.h>
    #import "Dog.h"
    int main (int argc, const char * argv[]) {
        
    	Dog *a = [Dog new];
    	[a setName:@"Fido"]; 
    	
    	Dog *b = [Dog new];
    	[b setName:@"Lucky"];
    	
    	Dog *c = [Dog new];
    	[c setName:@"Lola"];
    	
    	Dog *d = [Dog new];
    	[d setName:@"Hank"];
    	
    	[a bark];
    	[b bark];
    	[c howl];
    	[d howl];
    	
    	
        return 0;
    }
    
    Leaky, but it howls.
     
  7. Heisler98 thread starter macrumors member

    Joined:
    Oct 30, 2010
    #7
    Thanks you guys. Forgot that the guy said Objective-C was case sensitive. Just wish the gcc compiler was smart enough to figure out the actual problem rather than just tell you jargon that I have yet to figure out. :)

    But hey, it's NeXTStep, Darwin, and whatever other hell that's incorporated in there.
     

Share This Page