objective-c - 使用 RCocoa 在 R 中加载 objective-c 库

标签 objective-c r

我在 http://www.rforge.net/Cocoa/ 找到了 R 包 Cocoa ,我想用它来调用我自定义的 objective-c 类。

我尝试加载一个包含简单自定义类(如下所示称为 DOHello)的 dylib,然后调用:

hc <- .MClass("DOHello")
h <- .M(hc, "alloc")
h <- .M(h, "init")
.M(h, "hello")

前三行代码没问题,但是当我调用 .M(h, "hello") 时,整个 RStudio session 崩溃了。我也试过直接把DOHello的源码添加到Cocoa包中,结果是一样的。

DOHello 类:

@interface DOHello : NSObject 

- (void)hello;

@end


@implementation DOHello 

- (void)hello {
    printf("Hey, there");
}

@end

崩溃报告:

Process:         rsession [8215]
Path:            /Applications/RStudio.app/Contents/MacOS/rsession
Identifier:      rsession
Version:         ???
Code Type:       X86-64 (Native)
Parent Process:  RStudio [1931]
User ID:         502

Date/Time:       2013-03-04 11:47:44.858 +0800
OS Version:      Mac OS X 10.8.2 (12C54)
Report Version:  10

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.CoreFoundation        0x00007fff867d301d __NSI0 + 621
1   com.apple.CoreFoundation        0x00007fff867d2aee -[NSInvocation getArgument:atIndex:] + 302
2   Cocoa.so                        0x000000010c4fef4f ObjCsendMsg + 1135
3   libR.dylib                      0x0000000109ffee37 do_External + 327 (dotcode.c:540)
4   libR.dylib                      0x000000010a02e448 Rf_eval + 1672 (eval.c:494)
5   libR.dylib                      0x000000010a02fedd do_begin + 141 (eval.c:1415)
6   libR.dylib                      0x000000010a02e29c Rf_eval + 1244 (eval.c:468)
7   libR.dylib                      0x000000010a0333b1 Rf_applyClosure + 849 (eval.c:861)
8   libR.dylib                      0x000000010a02e1b2 Rf_eval + 1010 (eval.c:512)
9   libR.dylib                      0x000000010a0669e2 Rf_ReplIteration + 514 (main.c:256)
10  libR.dylib                      0x000000010a066cd1 R_ReplConsole + 161 (main.c:306)
11  libR.dylib                      0x000000010a0671ea run_Rmainloop + 90 (main.c:988)
12  rsession                        0x0000000109786b1b r::session::runEmbeddedR(core::FilePath const&, core::FilePath const&, bool, bool, SA_TYPE, r::session::Callbacks const&, r::session::InternalCallbacks*) + 427
13  rsession                        0x0000000109769b29 r::session::run(r::session::ROptions const&, r::session::RCallbacks const&) + 3193
14  rsession                        0x0000000109386f35 main + 14517
15  rsession                        0x000000010936e154 start + 52

崩溃报告不完整,我只是复制了我认为有用的部分。

最佳答案

这是 Cocoa 中的一个错误,它试图从 void 方法中检索结果 - 现已修复。请使用 stats-rosuda-devel 邮件列表或向作者发送电子邮件以获取问题和错误报告。

关于objective-c - 使用 RCocoa 在 R 中加载 objective-c 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15194366/

相关文章:

objective-c - 点击时 UICollectionViewCell 不显示 DetailView

objective-c - 当TableView的DataSource数组改变时,App崩溃

r - 无法使用 View() 或 edit() 函数,收到 "Error in .External2(C_dataviewer, x, title) : invalid device"错误消息

r - 每两列对数据帧的列应用一个函数,将该函数的结果存储在列表中,然后将该列表作为列插入

r - 根据行名和列名的数字和字符串将矩阵的元素相乘 (2)

r - 按组高效过滤多列

objective-c - Xcode cocoa通过计时器和 slider 连续操作同时更新界面

ios - 在表格 View 单元格中分页不同的图表

ios - Objective C setFrame 不适用于 UIView

r - 根据另一个列表 mutate() 一个列表