Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This repository was archived by the owner on May 28, 2025. It is now read-only.

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

@rupertdaniel

Description

@rupertdaniel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions