Reputation: 2436
I had a function that was supposed to return an NSURL, but I accidentally had it return an NSString. Xcode did not issue any warnings. Any idea why this is or how I can enable warnings for this. (It lead to a crash later in the app). Incidentally, if I change the function to return an NSMutableDictionary, I do get a compiler warning about incompatible return types. I am using Xcode 4.5.1.
-(NSURL *) urlForThing:(Thing *)thing
{
//This is clearly a string at compile time and I would expect a warning
//If I change this to [NSMutableDictionary alloc] I do get a warning
return [NSString stringWithFormat:@"thing://url/%@", thing];
}
Upvotes: 2
Views: 69
Reputation: 2436
Well, I suppose the short answer is that stringWithFormat:
returns an id
, not an NSString
. This doesn't make much sense to me, but it explains the lack of warning.
Upvotes: 2