Hi. I have just started looking into and coming from Win8 Cards using Visual Studio, I am trying to compare the two. I am not as familiar with Xcode so I was hoping to use the testApp and throw in some basic Lua/Intrerop code in there to test with. I see you have one example but do I create a main.m and stick that in there? Perhaps an example project which demonstrates the communication , return values to and from. Also some example or guide where I can use C++ libraries form Lua?
Just found this which helps.
https://forums.coronalabs.com/topic/50192-sending-data-from-lua-to-obj-c/
Looks like I need to rename the m file to mm. This changes to c++ compatible code right?
Actually I open up the SimpleView App and theres no Corona folder in the project and when I run it its blank.
An equivalent of this page would be helpful
https://docs.coronalabs.com/coronacards/wp8/communication.html
OKay so using the IOS example I have got obj c to lua but cant get it working the other way from Lua. I think i must be missing this delegate information . If you could explain what that should be as I tried the IOS version and it threw up lots of errors looking for ratatouille and things !
Making slow progress, but looking at the IOS Lua/interop forum post, I aded “view. coronaViewDelegate = self” and now I able to click on object but Xcode is giving me a warning “assigning id<coronaViewDelegate> from compatible type ViewController ’ cons__strong”
So I change
@interface ViewController : NSViewController
@end
to
@interface ViewController : NSViewController <CoronaViewDelegate>
@end
and that fixes the semantic warning even though in the IOS forum post they used this:
@interface ViewController : CoronaViewController <CoronaViewDelegate>
@end
which i tried and fails build so i change it back
I still have this warning though
ld: warning: directory not found for option ‘-F/Users/macbookpro/Library/Developer/Xcode/DerivedData/ratatouille-hgfkkhwimbyvgsarvdfmqlkdqtwj/Build/Products/Debug’
I do enjoy talking to myself.
You’re entering a brave new world. Let me see if I can get an Engineer respond to it.
Rob
I certainly am. I’m making progress actually. I have it all working. Now importing a c++ library and using that but now figuring how to pass that to Lua. Oh the fun
I have made good progress . I am getting a crash though now
2015-05-08 13:28:48.598 TestApp[10033:393035] Rtt_ASSERT [void lua_createtable(lua_State *, int, int)] at /Users/perry/src/corona/core/coronacards-main-tachyon-home/external/lua-5.1.3/src/lapi.c:582 (L->top < L->ci->top) 2015-05-08 13:28:48.599 TestApp[10033:393035] PANIC: unprotected error in call to Lua API (attempt to index a function value) 2015-05-08 13:28:48.600 TestApp[10033:393035] Rtt_ASSERT [static int Rtt::LuaContext::Panic(::lua_State *)] at /Users/perry/src/corona/core/coronacards-main-tachyon-home/librtt/Rtt_LuaContext.cpp:154 (Code should NOT be reached)
Could really do with that engineer now
2015-05-08 22:42:29.011 TestApp[15073:578886] Rtt_ASSERT [TValue *index2adr(lua_State *, int)] at /Users/perry/src/corona/core/coronacards-main-tachyon-home/external/lua-5.1.3/src/lapi.c:57 (idx != 0 && -idx <= L->top - L->base)
2015-05-08 22:42:29.012 TestApp[15073:578915] nil
I’m throwing some data fast into the the NS dictionary event and i think its either bottle necking or missing some data.
I just re-pinged them.
Rob
I believe I might be running code which should be in another thread? I don’t know if this is right or not but sounds like my problems might be arising from having some for and while loops in the view controller m file. I believe this might be a ui thread and so causing the communication to Lua view object hanging or unstable.
Unless your code is starting additional threads I can’t see how that would be an issue. I would also be careful about just trying stuff from iOS to see if it works in OS X, they are different operating systems and consequently the Corona SDK implementation may be different in its specifics.
In my testing for beta1 I used the sample code from this page which all worked correctly:
https://docs.coronalabs.com/daily/coronacards/osx/communication.html
It turns out that a callback to a library I was using was using a different thread so when I sent that to Lua it could crash randomly, I used dispatch queue and a new function to send to Lua and problem solved.
How can I get more than one Lua to Obj function?
I did naively try
(id)anotherFunction:(…
local event = { name=“anotherFunction”, message=“Hello from CoronaCards!” }
but guess its got to always be called coronaView? unless I can send a function name in the event table and then when that arrives on the obj c side, it runs .
Perhaps could make a dictionary in objc with receive messages as keys and the functions to run as the value or somthing like that if you know what i mean.
Just found this which helps.
https://forums.coronalabs.com/topic/50192-sending-data-from-lua-to-obj-c/
Looks like I need to rename the m file to mm. This changes to c++ compatible code right?
Actually I open up the SimpleView App and theres no Corona folder in the project and when I run it its blank.
An equivalent of this page would be helpful
https://docs.coronalabs.com/coronacards/wp8/communication.html