I have a following static method in one of my utility class
+ (UIImage *) getImage:(NSURL*) fromUrl { //Warning here
NSData *urlData = [NSData dataWithContentsOfURL:fromUrl];
UIImage *image = [[[UIImage alloc] initWithData:urlData] autorelease];
return image;
}
For this method I’m receiving a bellow warning message
warning: incompatible Objective-C
types initializing ‘struct NSURL *’,
expected ‘struct NSString *’
I did not noticed any exception, is this something I can ignore? Or how can I fix it?
The warning is correct in that there is a conflicting type and, as with all warnings, you should fix it.
More likely than not, you have two
getImage:methods declared, one that takes anNSStringand one that takes anNSURLas their sole argument. In Objective-C, the method namespace is flat and the recommended pattern is that there be only one declared argumentation for any given selector.There is a more subtle issue, though.
getImage:is not really as descriptive as it either could be nor as descriptive as standard practice would dictate.A better method declaration would be:
More descriptive. Less ambiguous.