加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

从Ruby on Rails执行Objective-C

发布时间:2020-12-17 02:00:34 所属栏目:百科 来源:网络整理
导读:我想在我的Rails应用程序中执行以下Objective-C代码: CFMutableStringRef inputString = CFStringCreateMutableCopy(kCFAllocatorDefault,32,CFSTR("общей"));CFLocaleRef locale = CFLocaleCreate(kCFAllocatorDefault,CFSTR("ru"));CFStringTransfor
我想在我的Rails应用程序中执行以下Objective-C代码:

CFMutableStringRef inputString = CFStringCreateMutableCopy(kCFAllocatorDefault,32,CFSTR("общей"));
CFLocaleRef locale = CFLocaleCreate(kCFAllocatorDefault,CFSTR("ru"));

CFStringTransform(inputString,NULL,kCFStringTransformStripDiacritics,false);
CFStringLowercase(inputString,locale);


NSLog(@"%@",(NSString *)inputString);

CFRelease(locale);
CFRelease(inputString);

它基本上输出一个小写的,不含变音符号的输入字符串版本.我在Snow Leopard服务器上运行.

我怎么能这样做(不使用MacRuby,这似乎是一个矫枉过正)?我听说过Ruby扩展但在我的案例中找不到任何资源.

解决方法

您无需创建应用程序,而是需要在单个Rails实例中打开和关闭,您可以使用其他通信方式编写应用程序,例如命名管道:

http://hints.macworld.com/article.php?story=20041025103920992
http://www.pauldix.net/2009/07/using-named-pipes-in-ruby-for-interprocess-communication.html

或者使用Ruby C扩展方式:

http://ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html
http://people.apache.org/~rooneg/talks/ruby-extensions/ruby-extensions.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读