zoukankan      html  css  js  c++  java
  • nodejs 调用 OC 方法

    nodejs 借助 nodobjc 模块 

    https://github.com/TooTallNate/NodObjC

    demo:

    var $ = require('nodobjc')
    
    $.framework('Foundation')
    $.framework('AppKit')
    
    var pool = $.NSAutoreleasePool('alloc')('init')
    
    var string = $.NSString('stringWithUTF8String', 'Hello')
    	// var string1 = $.NSString('stringWithUTF8String', 'Hello')
    	// var compare = string('compare',string1,'options','NSLiteralSearch|NSCaseInsensitiveSearch')
    
    // console.log(compare)
    
    var size = $.NSMakeSize(8, 'MAXFLOAT');
    var font = $.NSFont('systemFontOfSize', 20.0);
    var attributes = $.NSMutableDictionary('alloc')('init');
    attributes('setObject',font,'forKey',$('NSFontAttributeName'));
    var rect = string('boundingRectWithSize', size, 'options', 'NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading','attributes',attributes,'context',null);
    console.log(rect);
    
    pool('drain')
    
  • 相关阅读:
    Ruby--Array
    SQL--查询相同字段的数据
    Ruby--CSV
    Ruby--String
    Git常用命令
    JS Date函数操作
    FTP命令
    Rails--%w用法[转]
    Rails--export csv
    Mysql远程访问
  • 原文地址:https://www.cnblogs.com/levy/p/5698538.html
Copyright © 2011-2022 走看看