Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tomerw

macrumors newbie
Original poster
Apr 10, 2009
7
0
Newbie to xcode.
I wrote the following function :

+(NSString*) getImagePath:(int)selectedImage{
return @"something";
}

and I get a runtime error everytime I call it. Maybe i'm misunderstanding something about NSString ?
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
So one really useful tip is to copy/paste the actual error. Those details may not be meaningful to you yet, but it's good info for someone else trying to help.

Also, can you post the code that calls this method?

And lastly if you wrap code in code tags, it's much easier to read.
 

tomerw

macrumors newbie
Original poster
Apr 10, 2009
7
0
detailed (formatted) information about the problem

I tried stringWithString, same problem.
some more detailed information :

OpenerUtil.h
Code:
@interface OpenerUtil {}
+(NSString*) getImagePath:(NSInteger)selectedImage;

@end

OpenerUtil.m
Code:
#import "OpenerUtil.h"
@implementation OpenerUtil

+(NSString*) getImagePath:(NSInteger)selectedImage{
	return @"something";
}
@end

in MainView.h, I have :
Code:
#import OpenerUtil.h

And the call to the method looks like this :
Code:
NSString *test = [OpenerUtil getImagePath:0];

My Error looks like this :
Code:
2009-04-11 15:44:05.391 BeerOpener[581:20b] *** NSInvocation: warning: object 0x74e0 of class 'OpenerUtil' does not implement methodSignatureForSelector: -- trouble ahead
2009-04-11 15:44:05.399 BeerOpener[581:20b] *** NSInvocation: warning: object 0x74e0 of class 'OpenerUtil' does not implement doesNotRecognizeSelector: -- abort

If I move the getImagePath method to my MainView.m, it works.
What am I doing wrong here?

Thanks.
 

tomerw

macrumors newbie
Original poster
Apr 10, 2009
7
0
I don't explicitly use NSInvocation anywhere.
I do have two timers, but even if I disable both, the problem remains.
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
I don't explicitly use NSInvocation anywhere.
I do have two timers, but even if I disable both, the problem remains.

Well, if it's a direct method call like you posted, then you shouldn't be seeing an NSInvocation.

Something else is going on here. I'd have to see more code than what you're posting to be able to figure it out.

But to answer your general question, you can return a literal string @"Some String" directly as an NSString*. That part is not your problem. So I would look elsewhere.

Hope that helps.
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
OpenerUtil did not inherit from NSObject.

Oh, didn't even notice that. Just FYI, if it's a direct method call like [SomeClass someMethod:0], then that wouldn't matter.

But if you're using an NSInvocation (via a timer for example) then yes, your class needs be a subclass of NSObject.

Glad you figured it out.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.