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")

目录
相关文章
|
4月前
|
JavaScript 前端开发
Vue、ElementUI配合Node、multiparty模块实现图片上传并反显_小demo
如何使用Vue和Element UI配合Node.js及multiparty模块实现图片上传并反显的功能,包括前端的Element UI组件配置和后端的Node.js服务端代码实现。
72 1
|
8月前
|
安全
JSPatch被停用了,也就是不能使用JSPatch第三方框架热修复了
JSPatch被停用了,也就是不能使用JSPatch第三方框架热修复了
121 0
|
8月前
|
JavaScript API
Vue.js组件精讲 组件的通信2:派发与广播——自行实现dispatch和broadcast方法
Vue.js 的 provide/inject API 主要用于跨级组件通信,侧重于子组件获取上级状态。但无法良好处理两种场景:父向子(跨级)传递数据和子向父(跨级)传递数据。在这种情况下,虽然Vue推荐使用Vuex,但在某些场景下,可以使用自定义的`dispatch`和`broadcast`方法。这两个方法在Vue 1.x中存在,但在2.x中被废弃。`$emit`用于触发当前组件的自定义事件,而`$on`用于监听这些事件。在Vue 2.x中,我们将自行实现`dispatch`和`broadcast`以实现类似的功能,允许父子组件(包括跨级)之间的通信,特别是当组件层级不深且无需全面状态管理时
67 0
|
算法
vue2-patch流程分析
我们在上篇文章分析了虚拟节点的创建及渲染流程,其中也有简单分析了 patch 过程,但是对于新旧节点的对比逻没有去仔细分析,所以我们打算好好梳理下 patch 的整个流程。
|
Web App开发 JavaScript iOS开发
JSPatch 断点调试
JSPatch 断点调试
156 0
JSPatch 断点调试
|
JavaScript
JSPatch下发笔记3
JSPatch下发笔记3
130 0
|
JavaScript
JSPatch下发笔记4
JSPatch下发笔记4
134 0
|
JavaScript
JSPatch下发笔记10
JSPatch下发笔记10
119 0
|
JavaScript
JSPatch下发笔记1
JSPatch下发笔记1
124 0
JSPatch下发笔记5
JSPatch下发笔记5
123 0