Note that there are some explanatory texts on larger screens.

plurals
  1. POissue with NSOperationQueue, weakSelf and blocks
    text
    copied!<p>I have the following code:</p> <pre><code> [[AHPinterestAPIClient sharedClient] getPath:requestURLPath parameters:nil success:^(AFHTTPRequestOperation *operation, id response) { [weakSelf.backgroundQueue_ addOperationWithBlock:^{ [self doSomeHeavyComputation]; [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [weakSelf.collectionView_ setContentOffset:CGPointMake(0, 0)]; [weakSelf.collectionView_ reloadData]; [weakSelf.progressHUD_ hide:YES]; [[NSNotificationCenter defaultCenter] performSelector:@selector(postNotificationName:object:) withObject:@"UIScrollViewDidStopScrolling" afterDelay:0.3]; [weakSelf.progressHUD_ hide:YES]; }]; }]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { [weakSelf.progressHUD_ hide:YES]; [weakSelf.collectionView_.pullToRefreshView stopAnimating]; NSLog(@"Error fetching user data!"); NSLog(@"%@", error); }]; </code></pre> <p>For some reason this worked just fine in iOS 5, but not iOS 6 (it crashes). Now I am not going to ask about iOS 6 because it's still under NDA. What I want to know is, whether the code above is wrong? If yes how do I fix it. </p> <p>If I put the code inside the block outside of the mainQueue then it's fine. What I am trying to do here is to do the NSOperationQueue mainQueue only after the [self doSomeHeavyComputation] is done. So this is a dependency, how should I add this dependency?</p> <p>Update:</p> <p>Here's the crash log if it helps:</p> <p><img src="https://i.stack.imgur.com/SHa3E.png" alt="enter image description here"></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