trying to call an objective-c function from c within enterprise and AppCoronaDelegate.h

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 );

}  

make that AppCoronaDelegate.mm …

Figured it out… I created a new class containing the GPS method and called it from my AppCoronaDelegate function. online tutorials are a wonderful thing… 

make that AppCoronaDelegate.mm …

Figured it out… I created a new class containing the GPS method and called it from my AppCoronaDelegate function. online tutorials are a wonderful thing… 

Hi there. Old post I know, but we’re encountering the same issue and we do not understand how do you resolved. Can you share your working code?

Hi there. Old post I know, but we’re encountering the same issue and we do not understand how do you resolved. Can you share your working code?