原代碼
@implementation CommunityViewController
- (void)jump:(UIButton *)sender{
CommunityBannerModel *model = _arr[sender.tag];
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setValue:model.action_type forKey:@"type"];
[dict setValue:model.url forKey:@"value"];
[[PushJumpManager sharedInstance]pushActionWithModel:dict];
}
@end
JS代碼
require('NSMutableDictionary,PushJumpManager');
defineClass('CommunityViewController', {
jump: function(sender) {
var i = sender.tag();
var model = self.valueForKey("_arr").objectAtIndex(i);
console.log(model);
var dict = NSMutableDictionary.dictionary();
console.log(dict);
dict.setValue_forKey(model.valueForKey("action_type"), "type");
console.log(model.valueForKey("action_type"));
dict.setValue_forKey(model.valueForKey("url"), "value");
console.log(model.valueForKey("action_type"));
console.log(dict);
PushJumpManager.sharedInstance().pushActionWithModel(dict);
},
});
注意:
1.把需要用到的類寫在require方法里仔涩,相當(dāng)于引用。
2.實(shí)例變量的寫法蛹锰。
_arr 寫成 self.valueForKey("_arr")
3.數(shù)組下標(biāo)的寫法深胳。
arr[i]寫成arr.objectAtIndex(i)
4.jsonModel值的寫法。
model.url寫成model.valueForKey("url")
5.在調(diào)試的時(shí)候把需要打印的值用console.log()方法輸出到控制臺(tái)方便調(diào)試铜犬。