Using NSLog to print navigationType
I have the following paragraph:
- (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;
}
I would like to print the "navigationType" variable with NSLog, but I am 开发者_如何学Pythonunable to find a format specifier (e.g.: @"%@" or @"%d") that is compatible with the variable or does not cause the app to crash. Can anyone advise?
Try NSLog(@"NavigationType: %i", navigationType);
UIWebViewNavigationTypeLinkClicked
is typedef on NSUInteger
.
Use %lu
format specifier to print out the value.
精彩评论