【发布时间】:2016-05-11 05:56:50
【问题描述】:
我在这里使用 signalR 发送数据是我发送数据的代码。
manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
setUrl = [NSString stringWithFormat:@"%@%@",[UtilHelper sharedManager].WebServiceURL,@"Save"];
NSDictionary *parameters = [[NSDictionary alloc]initWithObjectsAndKeys:dicArray,@"products", nil];
__block NSMutableArray* json;
json = [[NSMutableArray alloc]init];
[manager POST:setUrl parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSError *writeError = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:responseObject options:NSJSONWritingPrettyPrinted error:&writeError];
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingMutableContainers
error:&writeError];
if ([[dic valueForKey:@"StatusMsg"] isEqualToString:@"Success"]) {
// save To S3 Bucket
[self sendPicture:[NSString stringWithFormat:@"%@",strProductId] : strPackageId];
[[results objectAtIndex:i] setValue:[NSNumber numberWithBool:YES] forKey:@"productsync"];
[[results objectAtIndex:i] setValue:[NSNumber numberWithBool:YES] forKey:@"editflag"];
[context save:nil];
}
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
现在我在 AppDelegate 收到 SignalR 响应
[hubConnection setReceived:^(NSString *message) {
NSLog(@"%@",message);
});
当 setReceived 调用我的 UI 时,这里是我的代码,我展示了我的 UIViewController,我展示并挂起 UI init
-(void)handlePlusOption{
__weak __typeof(&*self)weakSelf = self;
dispatch_async( dispatch_get_main_queue(), ^{
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
strongSelf.addProductVc = [[AddProductVC alloc] initWithNibName:addProductVcIdentifier bundle:nil];
strongSelf.nav = [[UINavigationController alloc] initWithRootViewController:strongSelf.addProductVc];
strongSelf.nav.modalPresentationStyle = UIModalPresentationFormSheet;
strongSelf.nav.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
strongSelf.nav.modalPresentationCapturesStatusBarAppearance = NO; // To hide status bar, doest work with UIModalPresentationPageSheet style
[self.navigationController presentViewController:strongSelf.nav animated:YES completion:NULL];
});
}
为什么 UI 在 setReceived 之前挂起?
【问题讨论】:
标签: ios objective-c signalr signalr-hub