- edited description
Incoherent "Code refers to unknown resource" warning
I don't understand why this warning is shown for this code
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MyDocument" withExtension:@"momd"];
but not for this using the pathForResource
NSString *path = [[NSBundle mainBundle] pathForResource:@"MyDocument" ofType:@"momd"];
NSURL *url = [NSURL fileURLWithPath:path];
Instead using bundleForClass the warning doesn't appear
NSURL *modelURL = [[NSBundle bundleForClass:self.class] URLForResource:@"MyDocument" withExtension:@"momd"];
I suppose I'm missing something, may you help me to understand if this is a bug?
Comments (5)
-
reporter -
repo owner It’s normal and expected that no diagnostic is emitted for the last case, because it’s doing
[NSBundle bundleForClass:self.class]
, which is too dynamic an expression to statically determine as referring to the main bundle.However diagnostics should be emitted for the first two cases. I have been unable to reproduce the false negative you report for the second case — in my tests a diagnostic is correctly emitted for
[[NSBundle mainBundle] pathForResource:@"MyDocument" ofType:@"momd"]
. Can you please double check if you can still reproduce this false negative in your project, and that the code in your actual project matches the example you posted here? -
repo owner - marked as minor
-
repo owner @dafi Can you please double check (with the latest version 1.6.2) if you can still reproduce this false negative in your project?
-
repo owner - changed status to invalid
Closing due to inability to reproduce. Please reopen if necessary.
- Log in to comment