I want to return an NSMutableString in my Foundation program. However, I get the following error:
warning: Semantic Issue: Incompatible pointer to integer conversion
returning ‘NSMutableString *’ from a function with result type ‘int’
for the following code:
int main (int argc, const char * argv[])
{
NSMutableString* result = @"testing";
[pool drain];
return result;
}
That’s your main function. As you can see from the declaration
int main(), it returns anint. In fact,main()is only allowed to return anint, which indicates failure or success (generally 0 means success and any other number is a program-specific error code). You can’t return anything else there — it’s just part of the language. If you’re trying to print the string, you can useNSLog(@"%@", result)orprintf("%s", [result UTF8String]).