JSPatch下发笔记6

简介: JSPatch下发笔记6

OC代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        [NSImagePicker showImagePickerFromViewController:self allowEditing:YES finishAction:^(UIImage *image) {
            if (image) {
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [[NSNetworking sharedManager]uploadimagesWithArray:@[image] success:^(id response) {
                [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
                NSDictionary *parameters = @{@"userDesId":kAccountInfo.desId,@"headPhoto":response[@"items"][0]};
                [[NSNetworking sharedManager]get:API_NEISHA_MODIFY parameters:parameters success:^(id responseModel) {
                    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
                    [WKProgressHUD popMessage:@"修改成功" inView:self.view duration:HUD_DURATION animated:YES];
                    _userHeaderUrl = [response objectForKey:@"items"][0];
                    [kTabbar.topViewControllers[4] performSelector:@selector(reloadViews)];
                    [self.tableView reloadData];
                } failure:^(NSString *error,int errorCode) {
                    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
                    [WKProgressHUD popMessage:error inView:self.view duration:HUD_DURATION animated:YES];
                }];
            } failure:^(NSString *error,int errorCode) {
                [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
                [WKProgressHUD popMessage:error inView:self.view duration:HUD_DURATION animated:YES];
            }];
            }
        }];
    }
}


JS代码:

require('NSImagePicker,MBProgressHUD,NSNetworking,WKProgressHUD,AccountManager,CLNNTabBarController');
defineClass('PersonalViewController', {
            tableView_didSelectRowAtIndexPath: function(tableView, indexPath) {
            if (indexPath.section() == 0) {
            var weakSelf = __weak(self);
            NSImagePicker.showImagePickerFromViewController_allowEditing_finishAction(self, YES, block('UIImage*', function(image) {
        if (image){
          MBProgressHUD.showHUDAddedTo_animated(weakSelf.view(), YES);
          NSNetworking.sharedManager().uploadimagesWithArray_success_failure([image], block('id', function(response) {
          MBProgressHUD.hideAllHUDsForView_animated(weakSelf.view(), YES);
          var arr = response.objectForKey("items"); 
          var parameters = {
          "userDesId": AccountManager.getInstance().accountInfo().desId(),
          "headPhoto": arr.objectAtIndex(0) 
}; 
          NSNetworking.sharedManager().get_parameters_success_failure("/api/user/modifyUserMsg", parameters, block('id', function(responseModel) {
          MBProgressHUD.hideAllHUDsForView_animated(weakSelf.view(), YES); 
          WKProgressHUD.popMessage_inView_duration_animated("修改成功", weakSelf.view(), 1.0, YES); 
          _userHeaderUrl = arr.objectAtIndex(0);
          weakSelf.setValue_forKey(_userHeaderUrl, "_userHeaderUrl");
          CLNNTabBarController.sharedInstance().topViewControllers().objectAtIndex(4).performSelector("reloadViews"); 
        weakSelf.tableView().reloadData(); 
        }), block('NSString*,int', function(error, errorCode) {
        MBProgressHUD.hideAllHUDsForView_animated(weakSelf.view(), YES);
        WKProgressHUD.popMessage_inView_duration_animated(error, weakSelf.view(), 1.0, YES); 
        }));
}), block('NSString*,int', function(error, errorCode) {
        MBProgressHUD.hideAllHUDsForView_animated(weakSelf.view(), YES);
        WKProgressHUD.popMessage_inView_duration_animated(error, weakSelf.view(), 1.0, YES);
})); 
} 
}));
}
 },
});


总结:


1.不可变数组表示方法,OC:@[image],JS:[image]。

2.字典取值方法:OC:response[@"items"][0],JS:response.objectForKey("items").objectAtIndex(0)

3.JS 私有变量block内赋值: weakSelf.setValue_forKey(_userHeaderUrl, "_userHeaderUrl");

4.选择器表示方法:

OC:performSelector:@selector(reloadViews)

JS:performSelector("reloadViews")

目录
相关文章
|
5月前
|
JavaScript 前端开发
Vue、ElementUI配合Node、multiparty模块实现图片上传并反显_小demo
如何使用Vue和Element UI配合Node.js及multiparty模块实现图片上传并反显的功能,包括前端的Element UI组件配置和后端的Node.js服务端代码实现。
89 1
|
9月前
|
安全
JSPatch被停用了,也就是不能使用JSPatch第三方框架热修复了
JSPatch被停用了,也就是不能使用JSPatch第三方框架热修复了
146 0
|
算法
vue2-patch流程分析
我们在上篇文章分析了虚拟节点的创建及渲染流程,其中也有简单分析了 patch 过程,但是对于新旧节点的对比逻没有去仔细分析,所以我们打算好好梳理下 patch 的整个流程。
|
Web App开发 JavaScript iOS开发
JSPatch 断点调试
JSPatch 断点调试
159 0
JSPatch 断点调试
|
JavaScript
JSPatch下发笔记2
JSPatch下发笔记2
151 0
|
JavaScript
JSPatch下发笔记8
JSPatch下发笔记8
136 0
|
JavaScript
JSPatch下发笔记10
JSPatch下发笔记10
123 0
|
JavaScript
JSPatch下发笔记9
JSPatch下发笔记9
116 0
|
JavaScript
JSPatch下发笔记7
JSPatch下发笔记7
143 0
JSPatch下发笔记5
JSPatch下发笔记5
126 0

热门文章

最新文章