Ipad Error: 'Program received signal EXC_BAD_ACCESS'
I am getting this error when I deploy to my iPad. It does not occur in the simulator.
My ipad app has three UIWebViews. The majority of this application is written completely as a web app, and uses CSS to make it look more native. Links that are clicked in the various web views will open in a certain one depending on the value of the request variable "iPadTarget."
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = [request URL];
//Extract the value from request开发者_StackOverflow社区 variable 'iPadTarget' in url string.
NSString *test = [url query];
int index = [test rangeOfString:@"iPadTarget="].location;
int target = index + 11;
NSLog(@"%i", target);
char c = [test characterAtIndex:target];
NSLog(@"%c",c);
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
if (c == '1') {
[viewOne loadRequest:request];
return NO;
} else if (c == '2') {
[viewTwo loadRequest:request];
return NO;
} else if (c == '3') {
[viewThree loadRequest:request];
return NO;
}
}
return YES;
[url release];
}
The above code locates the variable "iPadTarget" and extracts its value (1 to 3). Why am I get this strange error? Any help is appreciated.
The line
[url release];
is the source of your trouble. You are releasing an object you do not own. You acquired the url through the -URL method of the request, and as it does not contain new
, create
, or copy
you are not the owner. Remove the line [url release]
, and re-read the memory management guidelines.
精彩评论