Categories & singelton in cocoa

Posted by Nava Carmon on Stack Overflow See other posts from Stack Overflow or by Nava Carmon
Published on 2011-01-04T09:37:36Z Indexed on 2011/01/04 9:53 UTC
Read the original article Hit count: 276

Filed under:
|
|
|

Hi,

I have a SingletonClass, which has only one instance. I want to expand it and add to it a category (MoreFeatures).

I created a source SingletonClass+MoreFeatures, which interface/implementation looks like that:

@interface SingletonClass (MoreFeatures)

- (void) feature;

@end

@implementation SingletonClass (MoreFeatures)
- (void) feature()
{
}
@end

When I created my SingletonClass i followed the Apple's example of Singleton implementation in cocoa.

This singleton resides in a project B, which is a dependency of a bigger project A. I can call for [[SingletonClass sharedInstance] foo] from a source in project A and it works in case that function foo is located in SingletonClass interface/implementation. When I try to call [[SingletonClass sharedInstance] feature] from a source in project A, I get a crash, which says that there is no method feature for class SingletonClass...

Why it happens?

Thanks a lot,

Nava

EDIT: The crash happens in a runtime. The category file source resides in project B along with a SingletonClass

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about xcode