在C包装器中获取Objective-C值(Unity插件)

时间:2016-07-18 16:30:06

标签: ios objective-c c unity3d

我不熟悉Objecticve-C。我正在使用它,因为我想本地/正确检查ios上是否安装了应用程序。我找到了Objective-C片段,看看是否安装了一个应用程序并理解需要一个C-wrapper来基本上与Objective-C脚本(mm文件)进行统一对话。只是不明白如何让C-wrapper获取我在mm脚本中的Objective-C值。

// UnityPluginTest-1.mm
//
// Created by OJ on 7/13/16.
//
#import <Foundation/Foundation.h>  
@interface SampleClass:NSObject
/* method declaration */
- (BOOL)isFBInstalledX;
@end

@implementation SampleClass

//Objective-C value I want      
- (BOOL)isFBInstalledX {
return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]];
}

@end

//C-wrapper that talks to Unity
extern "C"
{
bool isFBInstalled(){

// Need to get the Objective C BOOL value from above, my c# script will get this value once retrieved


//return -(Bool) isFBInstalledX value  //--this doesn't work
//return ..... // I give up  :(

}


}

1 个答案:

答案 0 :(得分:0)