Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试从Unity调用C函数时链接失败_C#_Ios_Objective C_Xcode_Unity3d - Fatal编程技术网

C# 尝试从Unity调用C函数时链接失败

C# 尝试从Unity调用C函数时链接失败,c#,ios,objective-c,xcode,unity3d,C#,Ios,Objective C,Xcode,Unity3d,试图调用自定义目标C函数形式C。但它一直说它没有定义 每当我尝试在Xcode中构建时,它都会说_ShowDropIn是未定义的 该功能定义为: #import <Foundation/Foundation.h> //#import "BraintreeCore.h" #import <BraintreeCore.h> #import <BraintreeDropIn.h> @interface BrainTreeHandler : UIVie

试图调用自定义目标C函数形式C。但它一直说它没有定义

每当我尝试在Xcode中构建时,它都会说_ShowDropIn是未定义的

该功能定义为:

#import <Foundation/Foundation.h>
 //#import "BraintreeCore.h"



 #import <BraintreeCore.h>
 #import <BraintreeDropIn.h>


 @interface BrainTreeHandler : UIViewController
  #ifdef _cplusplus
  extern "C"{
      -(void)ShowDropIn:(const char *)clientTokenOrTokenizationKey;
  }
  #endif


  @end

  @implementation BrainTreeHandler

  #ifdef __cplusplus
  extern "C"
  {


  -(void)ShowDropIn:(const char *)clientTokenOrTokenizationKey{

      BTDropInRequest *request = [[BTDropInRequest alloc] init];
      BTDropInController *dropIn = [[BTDropInController alloc]initWithAuthorization:clientTokenOrTokenizationKey request:request      
 handler:^(BTDropInController * _Nonnull controller, BTDropInResult *      _Nullable result, NSError * _Nullable error) {

          if (error != nil) {
              NSLog(@"ERROR");
          } else if (result.cancelled) {
              NSLog(@"CANCELLED");
          } else {
              // Use the BTDropInResult properties to update your UI
              // result.paymentOptionType
              // result.paymentMethod
              // result.paymentIcon
              // result.paymentDescription
          }
      }];
      [self presentViewController:dropIn animated:YES completion:nil];

  }
  #endif

  @end
这个函数应该调用brain tree UI,但现在只给了我一个未定义的错误。

因此,在include-guard之后的每个C头文件的顶部,我们有

#ifdef __cplusplus
extern "C" {
#endif
在底部,我们写道

#ifdef __cplusplus
}
#endif
您不应在uu cplusplus之间包含函数定义


为什么这个问题被标记为C?这显然是关于Objective-C,这是一种完全不同的语言。我认为这毫无意义。我不是Objective-C大师,但不是-这意味着这是一个实例方法,然后在C中有一个没有任何名称空间的静态方法…?是的,很抱歉第一次尝试编写Objective-C。修复了我的问题。
#ifdef __cplusplus
}
#endif
-(void)ShowDropIn:(const char *)clientTokenOrTokenizationKey