[英]How to Expose Objective-C Pointer Method WithResultBuffer in IOS Binding
I'm trying to Invoke Objective-C Method 我正在尝试调用Objective-C方法
-(nabto_status_t)nabtoRpcInvoke:(NSString *)url withResultBuffer:(char
**)jsonResponse;
I used Objective-Sharpie Tool to generate the follow Method 我使用Objective-Sharpie Tool生成以下方法
[Export("nabtoRpcInvoke:withResultBuffer:")]
unsafe nabto_status_t RpcInvoke(string url, ref byte jsonResponse);
Please help expose me it correctly so i can get the JsonResponse String which i can use in IOS app. 请帮我正确揭露它,这样我就可以得到我可以在IOS应用程序中使用的JsonResponse字符串。
I Made these changes to Generated Method 我对Generated Method进行了这些更改
[Export("nabtoRpcInvoke:withResultBuffer:")]
unsafe nabto_status_t RpcInvoke(string url, ref IntPtr
jsonResponse);
and then I got the JsonResonse as follow. 然后我得到了JsonResonse如下。
IntPtr buff=new IntPtr() ;
status = Client.RpcInvoke(URL, ref buff);
byte[] newArray = new byte[buff.ToInt32() + 1];
for (int m = 0; m < buff.ToInt32(); m++)
{
byte b = Marshal.ReadByte(buff,m);
newArray[m] = b;
}
var JsonResponse = System.Text.Encoding.UTF8.GetString(newArray);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.