jspatch 学习
require('UIImage');
require('UIColor,UIButton,UITableView,UIScreen,UITableViewCell');
defineClass('JPViewController:UIViewController<UITableViewDataSource>', ['data'],{
viewDidLoad:function() {
self.super().viewDidLoad();
var view = self.view();
view.setBackgroundColor(UIColor.redColor());
self.setAutomaticallyAdjustsScrollViewInsets(0);
self.setEdgesForExtendedLayout(0);
var tableView = UITableView.alloc().initWithFrame_style({x: 0, y: 0, width: 375, height: 667}, 0);
tableView.setDataSource(self);
view.addSubview(tableView);
require('NSURLSession,NSURLRequest,NSURL,NSJSONSerialization');
var session = NSURLSession.sharedSession();
// 2.创建请求
var request = NSURLRequest.requestWithURL(NSURL.URLWithString("http://192.168.50.110:8081/urming_pkuie/system/getServiceHomePage?_=1478482875578"));
// 3.创建会话任务
session.dataTaskWithRequest_completionHandler(request, block('NSData*,NSURLResponse*,NSError*', function(data, response, error) {
// 1).序列化数据
var dic = NSJSONSerialization.JSONObjectWithData_options_error(data, 2, null);
// 2).将数据转
console.log(dic);
})).resume();
}
,
tableView_numberOfRowsInSection:function(tableView,section){
return 2;
},
tableView_cellForRowAtIndexPath:function(tableView,indexPath) {
var cell = tableView.dequeueReusableCellWithIdentifier("id");
if (!cell) {
cell = UITableViewCell.alloc().initWithStyle_reuseIdentifier(0, "id");
}
cell.textLabel().setText('smallTwo');
cell.textLabel().setTextColor(UIColor.redColor());
return cell;
}
})