IL2CPP 线程池工作者(54):EXC_BAD_ACCESS(代码=1,地址=0x10)
IL2CPP Threadpool worker(54): EXC_BAD_ACCESS (code=1, address=0x10)
我的插件:
#import <Foundation/Foundation.h>
@interface SampleClass:NSObject
+ (BOOL)isInstalledX: (NSString*) app;
+ (void)sendX: (NSString*) target;
@end
@implementation SampleClass
+ (BOOL)isInstalledX: (NSString*) app {
return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString: app]];
}
+ (void)sendX: (NSString*) target{
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:target]])
{
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:target]];
}
}
@end
NSString* convertString(const char* string)
{
return [NSString stringWithUTF8String: string];
}
extern "C"
{
bool isInstalled(const char* text){
return [SampleClass isInstalledX: convertString(text)];
}
void send(const char* url){
[SampleClass sendX: convertString(url)];
}
}
每次我尝试构建它时 returns IL2CPP Threadpool worker(54): EXC_BAD_ACCESS (code=1, address=0x10) 在线 return [NSString stringWithUTF8String: string];.
但是当我删除 send 函数时,isInstalled 函数中的转换正在工作。
还有 C# 代码:
[DllImport ("__Internal")]
private static extern bool isInstalled(string text);
[DllImport ("__Internal")]
private static extern void send(string text);
...
if (!isInstalled("fb-messenger://"))
btn.gameObject.SetActive(false);
...
send("fb-messenger://share?link=" + content);
我将函数 send
的名称更改为 sendToApplication
并且成功了...
我的插件:
#import <Foundation/Foundation.h>
@interface SampleClass:NSObject
+ (BOOL)isInstalledX: (NSString*) app;
+ (void)sendX: (NSString*) target;
@end
@implementation SampleClass
+ (BOOL)isInstalledX: (NSString*) app {
return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString: app]];
}
+ (void)sendX: (NSString*) target{
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:target]])
{
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:target]];
}
}
@end
NSString* convertString(const char* string)
{
return [NSString stringWithUTF8String: string];
}
extern "C"
{
bool isInstalled(const char* text){
return [SampleClass isInstalledX: convertString(text)];
}
void send(const char* url){
[SampleClass sendX: convertString(url)];
}
}
每次我尝试构建它时 returns IL2CPP Threadpool worker(54): EXC_BAD_ACCESS (code=1, address=0x10) 在线 return [NSString stringWithUTF8String: string];.
但是当我删除 send 函数时,isInstalled 函数中的转换正在工作。
还有 C# 代码:
[DllImport ("__Internal")]
private static extern bool isInstalled(string text);
[DllImport ("__Internal")]
private static extern void send(string text);
...
if (!isInstalled("fb-messenger://"))
btn.gameObject.SetActive(false);
...
send("fb-messenger://share?link=" + content);
我将函数 send
的名称更改为 sendToApplication
并且成功了...