OSX::OCMessageSendException: Can't get Objective-C method signature for selector

32 views
Skip to first unread message

Tim Haines

unread,
Aug 24, 2008, 5:24:22 PM8/24/08
to Ruby-based iPhone Testing
Hi there,

Nice work on getting this started. I've been playing with it a bit,
and am finding it pretty nice compared to not having tests. ;-) The
assert_equal test output is a little non-intuitive - it took me some
time to find the diffs were being output at the bottom - but now I'm
on to that I'm making some progress.

I'm having some problems with a method signature though. I have a
method that I can call fine when it has just one param - an integer.
When I add a second param (NSString *) my ruby unit tests don't seem
to find it though. I'm supposed to be able to pass it a normal ruby
string right?

My method call looks like this:

KanaMap.kanaForLevel(1, "kana1")

With my objc declaration:
+ (NSArray *)kanaForLevel:(int)level gameType:(NSString *)gameType;

And my defn:
+ (NSArray *)kanaForLevel:(int)level gameType:(NSString *)gameType {

I'm sure whatever I'm doing wrong is really simple - but I didn't
manage to figure it out last night. I get the same problem if the
method is an instance method. Here's the full error message:

1) Error:
test_initialised_with_correct_values(TestGame):
OSX::OCMessageSendException: Can't get Objective-C method signature
for selector 'kanaForLevel:' of receiver OSX::KanaMap
/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/
oc_wrapper.rb:50:in `ocm_send'
/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/
oc_wrapper.rb:50:in `method_missing'
./test/test_game.rb:33:in `test_initialised_with_correct_values'

Cheers,

Tim.


Tim Haines

unread,
Aug 24, 2008, 5:43:58 PM8/24/08
to Ruby-based iPhone Testing
Hmm - I've just had a look at the class of a string returned by a
property and it's NSCFString. I'm wondering if that has something to
do with it. Passing this in to another method signature that expected
a NSString worked correctly..

Tim.

Tim Haines

unread,
Aug 25, 2008, 4:52:07 AM8/25/08
to Ruby-based iPhone Testing
Okay, have this solved now after reading up on RubyCocoa. I needed to
prefix the method name with _secondParamName

So KanaMap.kanaForLevel(1, "kana1") worked after I changed it to:

KanaMap.kanaForLevel_gameType(1, "kana1")

Phew.

Tim.


On Aug 25, 9:24 am, Tim Haines <TMHai...@gmail.com> wrote:

Dr Nic Williams

unread,
Aug 25, 2008, 5:14:05 AM8/25/08
to rbipho...@googlegroups.com
Perhaps we need a transitioner's guide to rubycocoa somewhere. Perhaps
a few lines in generated test file?

Nic

Tim Haines

unread,
Aug 25, 2008, 5:25:51 AM8/25/08
to rbipho...@googlegroups.com
I think that would be helpful to newb's like me.  At first I thought the problem was was because the string wasn't being converted to a pointer, because all the RC docs say it's converted to NSString not an NSString pointer...   I probably would have saved two hours today if I saw an example of this early on.

The other thing that's worth reinforcing is that you need to add the classes to the project (or target or whatever it's called) inside xcode.  I saw you mentioned this in your screencast which was good..

Tim.
Reply all
Reply to author
Forward
0 new messages