I have a Swift project called TestSwift:
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate
{
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(_ aNotification: Notification)
{
print(#function + " self \(self)") // self <TestSwift.AppDelegate: 0x600000000820>
let a = OClass()
a.soSomething(for:self)
}
public func abc() { print(#function) }
}
I read somewhere that Xcode would generate a TestSwift-Swift.h header for me.
My Xcode (Version 9.4.1 (9F2000)) did not.
So I made:
@interface AppDelegate : NSObject
-(void)abc;
@end
Here is my Objective-C class:
#import "OClass.h"
#import "TestSwift-Swift.h"
@implementation OClass
- (void)soSomethingFor: (AppDelegate *)sender;
{
NSLog(@"%s sender %@",__FUNCTION__, sender); // sender <TestSwift.AppDelegate: 0x600000000820>
[ sender abc ]; // -[TestSwift.AppDelegate abc]: unrecognized selector sent to instance 0x600000000820
}
@end
Compiles fine, but gets this “unrecognized selector” error at run time.
What am I doing wrong?
Gerriet.