I am using Xcode 4.3.2 to develop iPhone apps with ARC enabled. while navigating in project no crash is there but when I saw the project execution using leaks tool it is showing malloc leak for may times I don;t know hoe to solve …
I used the following coding in project ..theme is to hiding a view with another view while loading data…..
[NSThread detachNewThreadSelector: @selector(StartActivityIndicator) toTarget:self withObject:nil];
-(void)StartActivityIndicator
{
hideView= [[UIView alloc] initWithFrame: CGRectMake(0,0,320,480)];
activityIndicator= [[UIActivityIndicatorView alloc] initWithFrame: CGRectMake(148,188, 24, 24)];
hideView.backgroundColor =[UIColor blackColor];
hideView.alpha=0.8;
[hideView addSubview:activityIndicator];
[self.view addSubview:hideView];
[activityIndicator startAnimating];
}
is there any error in this or any alternative to this coding..
And when ARC is enabled we have to take care of leaks or not …..
You don’t need to use a thread to show an animated activity indicator. Instead of
simply use
Using threads can easily lead to problems, for example by accessing UI-related classes and methods outside the main thread, or by using setters that were declared as nonatomic, or by forgetting to add an autoreleasepool, and so on. Don’t go there unless you have to. And if you have to, use grand central dispatch instead of creating your own threads. 🙂