Objective c 使用NSLog打印navigationType
我有以下一段:Objective c 使用NSLog打印navigationType,objective-c,ios,xcode,Objective C,Ios,Xcode,我有以下一段: - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType *)navigationType { NSURL * url = [request URL]; NSRegularExpression* regex = [[NSRegularExpression alloc]
- (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”)。有人能提供建议吗?试试
NSLog(@“NavigationType:%i”,NavigationType)
UIWebViewNavigationTypeLinkClicked
上的typedef是否为NSInteger
使用
%lu
格式说明符打印出值