Hey all,
I'm trying to develop a setAgeWithInt method in my .m file but keep getting a warning:
Assingment makes integer from pointer without a cast. I know this is a data type issue.
Here is my .h:
Code:
@interface Dog : NSObject {
NSString *name;
NSString *breed;
int age;
}
- (void) bark;
- (void) setName: (NSString *) n;
- (void) setBreed: (NSString *)b;
- (void) setAgeWithInt: (int *)x;
@end
Here is my .m:
Code:
#import "Dog.h"
@implementation Dog
- (void) bark {
NSLog(@"Woof, says %@. She is a %@ and she is %d years old.", name, breed, age); // %d is used for integer values.
}
- (void) setName:(NSString *)n {
name = n;
}
- (void) setBreed:(NSString *)b {
breed = b;
}
- (void) setAgeWithInt:(int *)x {
age = x;
}
Also, I'd like to create a setAge method that allows me to use float values. In the bark method, using %d, i'd like that to display the age whether it is int or float. Is this possible?
Thank you