Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try allocation of <code>HUD</code> on the <code>viewWillAppear:</code> instead of <code>-(IBAction)save</code> because sometimes allocation takes up the whole time and by the time it allocates whole task is finished.</p> <p>Copy Following links to <code>viewWillAppear:</code> and remove them from <code>-(IBAction)save</code></p> <pre><code> HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; [self.navigationController.view addSubview:HUD]; HUD.delegate = self; HUD.labelText = @"Saving..."; </code></pre> <p><strong>EDIT:</strong> Keep allocations on <code>viewWillAppear:</code> and change code as shown below:</p> <pre><code>- (IBAction)save { [NSThread detachNewThreadSelector:@selector(showHUD) withObject:nil]; [self performSelectorOnMainThread:@selector(savingPage) withObject:nil waitUntilDone:YES]; } - (void) savingPage{ NSString *title = [page stringByEvaluatingJavaScriptFromString:@"document.title"]; SavePageAs *savePage = [[SavePageAs alloc] initWithUrl:self.site directory:title]; [savePage save]; [HUD hide:YES]; } -(void)showHUD { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [HUD show:YES]; [pool release]; } </code></pre> <p>What this will do is create a separate thread to display HUD as main thread is being engaged by savingPage method.</p> <p>If this too doesn't work, then just change <code>waitUntilDone:YES</code> to <code>waitUntilDone:NO</code></p> <p><strong>Note:</strong> As per <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSAutoreleasePool_Class/Reference/Reference.html#//apple_ref/doc/uid/20000051-1722" rel="noreferrer">Apple documentation</a></p> <blockquote> <p>Important If you use Automatic Reference Counting (ARC), you cannot use autorelease pools directly. Instead, you use @autoreleasepool blocks instead. For example, in place of:</p> <pre><code>NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init; // Code benefitting from a local autorelease pool. [pool release]; </code></pre> <p>you would write:</p> <pre><code>@autoreleasepool { // Code benefitting from a local autorelease pool. } </code></pre> <p>@autoreleasepool blocks are more efficient than using an instance of NSAutoreleasePool directly; you can also use them even if you do not use ARC.</p> </blockquote> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload