ios native create event listener in objective-c

Sorry, I think you can clean up further. I did it quickly. Let me see what else I can remove. BRB.

I deleted the files and it still works. What is build.sh? I just plug in my phone and press the play button in xcode to test and the archive and upload to apple when ready. Delete it from your project you don’t need it. Tell me what error you get.

Sorry, my fault, you are correct. I deleted the files previously without deleting them from the project, I guess. Anyway, deleted them, still works. Having a bit of trouble calling a routine, but something in my code I am still tracking down. Because OpenEars is in the ‘other’ style (@implementation…), I have to translate everything to that format, but I am getting there. Thanks so much for your help.

thank you. I wanted some way to speak the Spanish words in my word search app. Recording 14,000 words weren’t going to happen even between my mom (she is always willing to help) and me. I think I can use this API to say them.

I am having trouble converting from one format to the other. I don’t know at this point which to commit to. 

When I use the @class IGOEController then I have to convert all the OpenEars routines which are written in the @implementation format. I can covert the simple ones, but how do I convert this:

-(void) pocketsphinxDidReceiveHypothesis:(NSString *)hypothesis recognitionScore:(NSString *)recognitionScore utteranceID:(NSString *)utteranceID {

This uses named parameters, and I don’t see how to duplicate that in the C-style function calls. 

If I convert the other way, it does not seem to recognize my functions. Particularly, this structure fails:

    // Functions in library

    const luaL_Reg kVTable[] =

    {

        { “loadOE”, loadOE },

         { “sttOn”, sttOn },

         { “sttOff”, sttOff }

        { NULL, NULL }

    };

The compiler says ‘Use of undeclared identifier’ for each routine, meaning it does not see the routine declarations:

  • (void)sttOn:(lua_State *)L {

    NSLog(@“turn on OE”);

}

  • (void)sttOff:(lua_State *)L {

    NSLog(@“turn off OE”);

}

  • (void)loadOE:(lua_State *)L {

I’ll keep digging into how to do each in the other format, but let me know if you have a recommendation. 

It still seems like so much extra coding to connect to a Lua listener (I only ever raise events with simple calls, not using listeners). I just wish there were a simple way to declare an Objective-C function an event listener, as simple as it is in Lua. Oh, well. 

Why are you converting them? Put a reference to the header file on the top and call them. If there is something that needs to be implemented. Create object C classes and implement them there then add the header file to your file and call it. I think you are making this a lot more complicated than it needs to be, but I might be missing something obvious.

Import:

#import \<Skillz/Skillz.h\>

Call it:

 [[Skillz skillzInstance] initWithGameId:@"xxx" forDelegate: skillzDelegate withEnvironment:SkillzProduction allowExit: YES];

If you need to implement something in object C you can do it either in a separate file or include it in the file. Above call requires a SkillzDelegate. The entire delegate is sitting in the C++ file:

// // Skillz // @interface SkillzDelegate : NSObject\<SkillzDelegate\> @end @implementation SkillzDelegate - (void)tournamentWillBegin:(NSDictionary \*)gameParameters withMatchInfo:(SKZMatchInfo \*)matchInfo { } - (void)skillzWillExit { // This code is called when exiting the Skillz portal //back to the normal game. } - (SkillzOrientation)preferredSkillzInterfaceOrientation { // return SkillzPortrait for portrait based applications // return SkillzLandscape for landscape based applications return SkillzLandscape; } @end static SkillzDelegate\* skillzDelegate = [[SkillzDelegate alloc] init];

If I understand you correctly, build a bridge from the Lua-C code to the OpenEars C++ code? Call the Lua-C code from Lua the way it all works, and then from that routine, call the C++ routine that I want called. Is that right? The Lua->C routines then sit between the Lua calls and the OpenEars routines? So making a direct Lua -> C++ routines is not a good idea, because of too many conversions, right?

Thank you! It all works now, that was the perfect suggestion, and much simpler than what I was trying to do. 

I still think it would be brilliant if Corona could set up to allow C or C++ routines to declare themselves as event listeners. But I am all good to go, thank you again.