Skip to content

Instantly share code, notes, and snippets.

@johnny77221
Created October 29, 2020 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnny77221/2aa65f3610c2da7e5754daa8045a43f7 to your computer and use it in GitHub Desktop.
Save johnny77221/2aa65f3610c2da7e5754daa8045a43f7 to your computer and use it in GitHub Desktop.
import UIKit
class SwiftUser: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
TestLib().myFunc()
}
}
import Foundation
@objc class TestLib: NSObject {
@objc fileprivate func _myFunc() {
print("I am here")
}
}
#import "test-Swift.h"
@interface TestLib (Ext)
-(void)myFunc NS_SWIFT_UNAVAILABLE("objc only");
@end
#import "TestLib_Objc.h"
@implementation TestLib(Ext)
-(void)myFunc {
[self performSelector:NSSelectorFromString(@"_myFunc")];
}
@end
@interface TestObjcUser: NSObject
@end
@implementation TestObjcUser
- (instancetype)init
{
self = [super init];
if (self) {
[[[TestLib alloc] init] myFunc];
}
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment