Module for iOS - objective C

Monkey Targets Forums/iOS/Module for iOS - objective C

Xaron(Posted 2011) [#1]
Hi all,

I'm rather experienced when it comes to C++ but a rookie when it's about objective c.

I'd like to create expand my net module with the iOS part but still scratch my head about all this objective C stuff here and there.

As far as I can see the iOS code of mojo is done with C++. But you need interface definitions and implementations which are done in a .h (interface) and .m file (implementations) usually.

Here for monkey all we have is a cpp file so I guess I can forget about all these .h and .m files and just put everything in the cpp file?

Could someone please post a simple example for a function like:

Function Get:String( test:string )
End Function


where you have a string as parameter for iOS and get a string back (I guess this will be NSString*)?

Thanks!


xzess(Posted 2011) [#2]
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html

Maybe this is useful for you

I did not tested this yet, but you can give this a try:


String myclass::GetString(String test)
{
NSString teststr = test.ToNSString()
return String(teststr);
}

String myclass::GetString()
{
NSString list = @"Norman, Stanley, Fletcher";
return String(list);
}


Xaron(Posted 2011) [#3]
Alright, thanks, this actually did work that way:

String GetString( String str )
{
  NSString *testStr = str.ToNSString();
  NSString *response = [NSString stringWithFormat:@"Test"];
  return String( response );
}