Hey all,
I get following error:
objective-c compile error: Initializing NSString with an expression of incompatible type void.
Basically my speak instance method should return a string and then I want to output that string as part of a message:
Here's basically my problem. Since objective-c uses the NNString class as its string implementation, I am not sure how to return it as the value of speak.
thanks for response
I get following error:
objective-c compile error: Initializing NSString with an expression of incompatible type void.
Basically my speak instance method should return a string and then I want to output that string as part of a message:
Code:
Animal *animal = [[Animal alloc] init];
NSString *speak = [animal speak];
NSLog(@"The animal says %@", speak);
Code:
@implementation Animal
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)speak{
NSLog(@"Hi there");
}
@end
Here's basically my problem. Since objective-c uses the NNString class as its string implementation, I am not sure how to return it as the value of speak.
thanks for response