Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-[NSObject conformsToProtocol:] does not work. #2934

Open
rupertdaniel opened this issue Dec 5, 2019 · 0 comments
Open

-[NSObject conformsToProtocol:] does not work. #2934

rupertdaniel opened this issue Dec 5, 2019 · 0 comments

Comments

@rupertdaniel
Copy link

Using the latest pre-release 0.2.180221-dev-20180516000001 -[NSObject conformsToProtocol:] does not work.

To reproduce the issue the Protocol, the object that implements the Protocol, and the code that calls -[NSObject conformsToProtocol:] need to be in separate source files.

If all 3 are defined in the same source file then it works as expected.

For example:

TestProtocol.h

#import <Foundation/Foundation.h>
@protocol TestProtocol <NSObject>
@end

TestObject.h

#import <Foundation/Foundation.h>
#import  "TestProtocol.h"

@interface TestObject : NSObject <TestProtocol>

@end

TestObject.m

#import "TestObject.h"
@implementation TestObject

@end

In some other source file...

TestObject *to = [[TestObject alloc] init];
if ([to conformsToProtocol:@protocol(TestProtocol)]) {
	NSLog(@"YES");
} else {
	NSLog(@"NO");
}

This will result in conformsToProtocol: to return FALSE and printing NO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant