Trying to use a obj-c extension in my swift project:
UIBezierPath+hello.h
#import <UIKit/UIKit.h>
@interface UIBezierPath(hello)
- (void)hello;
@end
UIBezierPath+hello.m
#import "UIBezierPath+hello.h"
@implementation UIBezierPath(hello)
- (void)hello
{
NSLog (@"hello hello");
}
@end
Bridging-Header.h
#import "UIBezierPath+hello.h"
Swift
let helloPath = UIBezierPath()
helloPath.hello()
It does build and it does sees the hello method. But it does crush:
-[UIBezierPath hello]: unrecognized selector sent to instance 0x7d2116d0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIBezierPath hello]:
unrecognized selector sent to instance 0x7d2116d0'
It seems it does not recognises the implementation.
Probably it does not work because I am dumb:)
Custom obj-c classes work in swift. Only extension give me this problem
Thanks guys
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…