私は完全に困惑しています。モノからObj-Cコードにセレクタを使用して変換することはできません。MonoTouchからSelectorを使用してObj-Cを呼び出す
@implementation MonoWrapper
- (id)init {
self = [super init];
if (self) {
NSBundle *main = [NSBundle mainBundle];
NSString *path = [main bundlePath];
const char *c_path = [path UTF8String];
[main autorelease];
[path autorelease];
chdir (c_path);
setenv ("MONO_PATH", c_path, 1);
setenv ("MONO_XMLSERIALIZER_THS", "no", 1);
setenv ("DYLD_BIND_AT_LAUNCH", "1", 1);
setenv ("MONO_REFLECTION_SERIALIZER", "yes", 1);
_domain = mono_jit_init_version ("MonoTouch", "v2.0.50727");
MonoAssembly *assembly = mono_assembly_open("PhoneGap.dll", NULL);
MonoImage *image = mono_assembly_get_image(assembly);
MonoClass *class = mono_class_from_name(image, "PhoneGap", "PhoneGap");
MonoMethodDesc *methodDesc = mono_method_desc_new("PhoneGap.PhoneGap:getInt", TRUE);
_callbackMethod = mono_method_desc_search_in_class(methodDesc, class);
/* allocate memory for the object */
_instance = mono_object_new (_domain, class);
/* execute the default argument-less constructor */
mono_runtime_object_init (_instance);
}
// Done
return self;
}
- (void)DoSomething {
int jim = 0;
}
- (int)multiplyA:(int)a {
void *params[] = { self, @selector(DoSomething), &a };
MonoObject *result = mono_runtime_invoke(_callbackMethod, _instance, params, NULL);
int n = *(int*)mono_object_unbox (result);
return n;
}
@end
そしてMonoTouchで中:だから、土壇場の試みとして、私は、コードを掲載してい
using System;
using MonoTouch.ObjCRuntime;
namespace PhoneGap
{
public class PhoneGap
{
public PhoneGap()
{
}
public int getInt(IntPtr instance, IntPtr sel, int val) {
Messaging.void_objc_msgSend (instance, sel);
return val * 2;
}
}
}
誰がどのようにセレクタを取得する方法をモノにターゲットインスタンスハンドルを取得すると教えてもらえます?
おかげ
ジェームズ