使用NSLog打印navigationType

时间:2011-09-30 09:39:58

标签: objective-c ios xcode

我有以下段落:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType *)navigationType {
    NSURL * url = [request URL];
    NSRegularExpression* regex = [[NSRegularExpression alloc] initWithPattern:@"loggedout" options:(NSRegularExpressionOptions)NSCaseInsensitiveSearch error:NULL];
    NSString *urlString = [url absoluteString];
    NSUInteger numberOfMatches = [regex numberOfMatchesInString:urlString options:0 range:NSMakeRange(0, [urlString length])];    
    [regex release];
    if (numberOfMatches > 0) {
//        NSLog(@"%@", url);
//        NSLog(@"%i", numberOfMatches);
        [self.navigationController popViewControllerAnimated:YES]; 
        return NO;
    }
    if (UIWebViewNavigationTypeLinkClicked == navigationType)
    {
        [[UIApplication sharedApplication] openURL:url];
        return NO;
    }
    return YES;
}

我想用NSLog打印“navigationType”变量,但我找不到与变量兼容或不导致的格式说明符(例如:@“%@”或@“%d”)崩溃的应用程序。有人可以建议吗?

2 个答案:

答案 0 :(得分:0)

尝试NSLog(@"NavigationType: %i", navigationType);

答案 1 :(得分:0)

UIWebViewNavigationTypeLinkClickedNSUInteger上的typedef 使用%lu格式说明符打印出值。