Calling Objective-c method that has underscore

189 views
Skip to first unread message

lammert

unread,
Dec 28, 2011, 4:42:25 AM12/28/11
to iPhone Wax
When calling an objective c method from LUA, the underscore character
is used to separate arguments. But what if the actual method name
contains underscores? Then how can that be called?

Example method:
- (NSString*) some_randomMethod:(int)arg1 and:(int)arg2;

The following with not work from LUA:
myInstance:some_randomMethod_and(1, 2)

This will assume that there are 3 arguments like this:
- (NSString*) some:(id)some randomMethod:(int)arg1 and:(int)arg2;

Any help would be greatly appreciated.

Corey Johnson

unread,
Dec 28, 2011, 12:47:22 PM12/28/11
to ipho...@googlegroups.com
Right now there is no way to do this via Wax. It assumes the Objective-C code matches the Cocoa style of using CamelCase method names. A workaround would be to make a Objective-C method that calls the method with args, something like this

# lua
SomeClass.callThatWeirdMethodWithArg1_arg2(arg1, arg2)


// Objective-C

+ (id)callThatWeirdMethodWithArg1:(int)arg1 arg2:(int)arg2 {
return [someWierdObject some_randomMethod:arg1 arg2:arg2];
}

Not a great solution, there are solutions where you could force wax to use a specific selector, but I haven't implemented those.

Corey

wangoc...@gmail.com

unread,
Nov 4, 2013, 9:56:04 PM11/4/13
to ipho...@googlegroups.com, weste...@gmail.com
hello,recently I have encountered this issue.Can you give me an example about how to call an objective c method from LUA? 
Thank you very much.

在 2011年12月28日星期三UTC+8下午5时42分25秒,lammert写道:
Reply all
Reply to author
Forward
0 new messages