我有以下段落:
- (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”)崩溃的应用程序。有人可以建议吗?
答案 0 :(得分:0)
尝试NSLog(@"NavigationType: %i", navigationType);
答案 1 :(得分:0)
UIWebViewNavigationTypeLinkClicked
是NSUInteger
上的typedef
使用%lu
格式说明符打印出值。