Hey you guys.
I'm new to OBjective C and Coca programming, but catching up well and liking the environment.
Today I encountered a somewhat strange problem though.
I was writing a simple function that returns a string:
Building it gave the warning:
Warning: return makes pointer from integer without a cast
If fixed it by using:
But why didn't it work in the first place?
I'm quite curious in understanding the difference between:
and
Thanks.
I'm new to OBjective C and Coca programming, but catching up well and liking the environment.
Today I encountered a somewhat strange problem though.
I was writing a simple function that returns a string:
Code:
-(NSString *) description
{
return (@"Hello I'm a %@ with %d sides", [self name], [self numberOfSides]);
}
Building it gave the warning:
Warning: return makes pointer from integer without a cast
If fixed it by using:
Code:
-(NSString *) description
{
return [NSString stringWithFormat:@"Hello I'm a %@ with %d sides %@", [self name], [self numberOfSides]];
}
But why didn't it work in the first place?
I'm quite curious in understanding the difference between:
Code:
return (@"Hello I'm a %@ with %d sides", [self name], [self numberOfSides]);
Code:
return [NSString stringWithFormat:@"Hello I'm a %@ with %d sides %@", [self name], [self numberOfSides]];
Thanks.