Note that there are some explanatory texts on larger screens.

plurals
  1. POAFNetworking multiple uploads slowing down main thread
    primarykey
    data
    text
    <p>I have a <code>UITabBarController</code> where UITableViewControllerA list files and UITableViewContollerB shows the progress of the files being uploaded.</p> <p>I have a Singleton class with an upload method that calls my subclass <code>AFHTTPClient</code> and uses <code>NSNotificationCenter</code> to notify my UITableViewControllerB of the upload progress. But this current way is slowing down the UI to where it is almost unusable and I'm not sure how I can improve the process. I read that AFNetworking callback functions are called on the main thread. Is the slow UI response coming from my NSNotificationCenter? </p> <p>I also would like to mention I'm running this on the Simulator.</p> <p>Method from my Singleton class.</p> <pre><code> NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; [dict setObject:uniqueName forKey:@"unique"]; [dict setObject:[NSNumber numberWithFloat:0] forKey:@"progress"]; [self.active addObject:dict]; [[CustomHTTP client] uploadFileName:@"filename" withBytes:data toPath:serverPath progress:^(float progress) { [dict setObject:progress forKey:@"progress"]; NSMutableDictionary *info = [[NSMutableDictionary alloc] init]; [info setObject:[NSNumber numberWithInt:[self getIndexByUniquename:uniqueName]] forKey:@"row"]; [[NSNotificationCenter defaultCenter] postNotificationName:@"ProgressNotification" object:self userInfo:info]; } success:^(AFHTTPRequestOperation *operation, id responseObject) { } andFailure:^(AFHTTPRequestOperation *operation, NSError *error) { }]; </code></pre> <p>UITableViewControllerB.m</p> <pre><code>- (void) receiveTestNotification:(NSNotification *) notification { if ([[notification name] isEqualToString:@"ProgressNotification"]) { NSDictionary *dict = notification.userInfo; int row = [[dict objectForKey:@"row"] intValue]; self.inProgress = [Transfer defaultTransfer].active; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0]; [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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