Understood, thanks.

Luca.

On Jan 15, 2013, at 4:31 PM, Uli Kusterer <witness.of.teacht...@gmx.net> wrote:

> On Jan 15, 2013, at 3:18 PM, Luca Ciciriello <luca_cicirie...@hotmail.com> 
> wrote:
>> I use an activity indicator in order to show, in my UIViewController, a 
>> "work in progress" activity.
>> 
>> here my code 
>> 
>> - (void)myMethod
>> {
>>      [[self activityElab] setHidden:NO];
>>      [[self activityElab] startAnimating];
>> 
>>      // here I call a very CPU-intensive method. 
>> 
>>      [[self activityElab] setHidden:YES];
>>      [[self activityElab] stopAnimating];
>> }
>> 
>> My problem is that nothing appear (activity indicator) when myMethod is 
>> called. Now if I remove (comment) the call to my "intensive activity" method 
>> all is working fine.
>> 
>> Any idea? I've tested this code both on the simulator and on a device (iPad) 
>> with  iOS 5.0 and iOS 6.0
>> My environment is Xcode 4.5.2 on OS X 10.8.2.
> 
> 
> That won't work. Views are only redrawn once your method returns. So while 
> your activity indicator is shown and hidden, nobody will ever see it. If you 
> do activities that take a long time, you'd better split them up into smaller 
> NSOperations which let the main thread redraw the UI in between each 
> operation. Or if you have to, use a separate thread, but that's hard to get 
> right, and easy to get wrong in a way that causes random hard-to-find crashes.
> 
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> http://www.zathras.de
> 
> 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to