I have a class that extends UIViewController and implements the UIWebViewDelegate, like this:
@interface TableViewController : UIViewController <UIWebViewDelegate, UIAlertViewDelegate>{
UIWebView *articleWebView;
NSString *link;
UIActivityIndicatorView *activityIndicator;
NSURL * safariUrl;
}
I'm trying to load a web page into the uiwebview, everything works fine, but i'm getting some leaks (like GeneralBlock-56, GeneralBlock-1024 etc) and i can't find out where they come from.
This is what i am doing:
- (void)viewDidLoad {
[super viewDidLoad];
if (articleWebView){
[articleWebView loadHTMLString: @"" baseURL: nil];
[articleWebView release];
articleWebView = nil;
}
articleWebView = [[UIWebView alloc] initWithFrame: CGRectMake(0,0,320,380)];
if (activityIndicator){
[activityIndicator release];
activityIndicator = nil;
}
activityIndicator = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(self.view.bounds.size.width/2-24, self.view.bounds.size.height/3-12, 50, 50)];
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
[self.view addSubview:activityIndicator];
link = [link stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
link = [link stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
link = [(NSString*) CFURLCreateStringByAddingPercentEscapes (NULL, (CFStringRef)link, NULL,
NULL, kCFStringEncodingUTF8) autorelease];
NSURL *url = [NSURL URLWithString:link];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[[self articleWebView] setDelegate: self];
[articleWebView loadRequest:requestObj];
[link release];
}
//////////////////////////////////////////////
-(void)webViewDidFinishLoad:(UIWebView *)webView{
if (activityIndicator){
[activityIndicator stopAnimating];
[activityIndicator release];
activityIndicator = nil;
self.view = articleWebView;
}
//////////////////////////////////////////////
- (void)viewDidUnload {
[super viewDidUnload];
[articleWebView loadHTMLString: @"" baseURL: nil];
[self.articleWebView release];
self.articleWebView = nil;
}
//////////////////////////////////////////////
- (void)dealloc {
self.articleWebView.delegate=nil;
[super dealloc];
}
What am i doing wrong? Thank you in advance.