Last active
May 25, 2017 03:29
-
-
Save sahara-ooga/a854a8df65d35c998def8e8a2ac370e9 to your computer and use it in GitHub Desktop.
プロトコルに準拠したid型の利用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ObjcClass.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let objectConformsSomeProtocol = ObjcClass.objectConformsSomeProtocol() | |
objectConformsSomeProtocol?.doSomething() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@protocol SomeProtocol | |
-(void)doSomething; | |
@end | |
@interface ObjectConformsSomeProtocol:NSObject<SomeProtocol> | |
@end | |
@interface ObjcClass:NSObject | |
+(id<SomeProtocol>)objectConformsSomeProtocol; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ObjcClass.h" | |
@implementation ObjectConformsSomeProtocol | |
-(void)doSomething{ | |
NSLog(@"Do Something."); | |
} | |
@end | |
@implementation ObjcClass | |
+(id<SomeProtocol>)objectConformsSomeProtocol{ | |
return [ObjectConformsSomeProtocol new]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment