Everything compiles fine and executes from lua, but will not fire turnGPSOn. Stepping through in Xcode it steps over the method call. Any help would be appreciated. If you are a c or objective-c coder it should be obvious I am not fluent in either…
@implementation AppCoronaDelegate
id thisclass;
// objective c
-(int)turnGpsOn:(NSString *)param1 {
//**Init location manager
CLLocationManager* locationManager = [[CLLocationManager alloc] init];
thisclass = self;
locationManager.delegate = self; //we must implement the protocol
//**Choose your accuracy level
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
//**To turn on gps (if it isn’t on already)
[locationManager startUpdatingLocation];
//**To turn gps off (if no other apps are listening)
//[locationManager stopUpdatingLocation];
NSLog(@“gpaParm2 from IOS = %@”, param1);
return (1);
}
// [lua] gpsStuff.gpsOn()
static int
gpsOn( lua_State *L )
{
//printf(“gpsStuff.gpsOn in plugin!\n”);
NSString *gpsParm = [NSString stringWithUTF8String:lua_tostring( L, 1 )];
NSLog(@“gpaParm from IOS = %@”, gpsParm);
// call turnGpsOn
int returnValue = [thisclass turnGpsOn:gpsParm];
// for lua testing return back to lua
//int returnValue = 1;
char buffer[sizeof(returnValue)*1];
sprintf( buffer, “%x”,returnValue );
lua_pushstring( L, buffer );
return 1;
}
- (void)willLoadMain:(id<CoronaRuntime>)runtime
{
lua_State *L = runtime.L;
const luaL_Reg kFunctions[] =
{
“gpsOn”, gpsOn,
NULL, NULL
};
luaL_register( L, “gpsStuff”, kFunctions );
lua_pop( L, 1 );
}