0

I have faced a tough problem.

NSURL *url = [NSURL URLWithString:@"numberplate://"];
if([[UIApplication sharedApplication] canOpenURL:url]){
    NSLog(@"it can");
}

Just create a empty project, insert the codes above into the method of didFinishLaunchingWithOptions in appdelegate.m

I run it on simulator, it runs ok. I run it on my Device,iOS 7.0.4, it crash.

But i run it on other people's device, it runs ok.

So, the problem is just occur on my device.

Also, if I change the string @"numberplate://" to any other strings, it also runs ok.

Has anybody faced this problem?

==========add edit=============

@demosten

@try {
    NSURL *url = [NSURL URLWithString:@"numberplate://"];
    if([[UIApplication sharedApplication] canOpenURL:url]){
        NSLog(@"success");
    }
}
@catch (NSException * e) {
    NSLog(@"Exception: %@", e);
}
@finally {
    NSLog(@"finally"); 
}

I change the code like this. But it can not catch the exception.

denggang
  • 11
  • 2

1 Answers1

0

Do you have any custom code in your appDelegate in the method below?

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{}

Inappropriate handler could possible be a reason.

soprof
  • 326
  • 2
  • 6
  • No, if i change a character the code just like below,it runs ok. NSURL *url = [NSURL URLWithString:@"numberplate11://"]; if([[UIApplication sharedApplication] canOpenURL:url]){ NSLog(@"it can"); } – denggang Apr 25 '14 at 09:07
  • just add "11" or any other characters, it also runs ok. – denggang Apr 25 '14 at 09:09