This is not how it works. You cannot just return something to C and expect it to appear in Unity / C #. To achieve two-way communication, you will need to do the following.
Unity => iOS
C # code
[DllImport ("__Internal")] private static extern void _SomeCMethod(string parameter);
(Objective-) C code
void _SomeCMethod(const char *parameter) { }
When you call _SomeMethod in C #, _SomeMethod in your (Objective-) C code is called.
iOS => Unity
Objective-C code
- (void)callSomeCSharpMethod UnitySendMessage("GO", "SomeCSharpMethod", "parameter"); }
C # code ( MonoBehaviour script attached to GO )
void SomeCSharpMethod(string parameter) { }
When you call callSomeCSharpMethod in Objective-C, SomeCSharpMethod is SomeCSharpMethod in C # code.
String conversion
You will need to convert the NSString strings to c ( const char * ) and vice versa.
const char * => NSString
[NSString stringWithCString:string encoding:NSUTF8StringEncoding]
NSString => const char *
[string cStringUsingEncoding:NSUTF8StringEncoding]
Note: This is a simple example of how to achieve a two-way communication channel between C # and native iOS code. Of course, you do not want to hard code, for example. The name is GameObject in your code, so you can just pass that name (for callbacks from Objective-C) to your native iOS code at the very beginning.
source share