This file contains 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 UIKit | |
extension String { | |
private var attributedStringOptions: [NSAttributedString.DocumentReadingOptionKey: Any] { | |
return [ | |
.documentType: NSAttributedString.DocumentType.html, | |
.characterEncoding: String.Encoding.utf8.rawValue | |
] | |
} |
This file contains 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
// AdditionFrameworkInterop.m | |
#import "AdditionFrameworkInterop.h" | |
@import AdditionalSDK; | |
// You can adopt protocols from additional framework even if its weak linked | |
@interface AdditionFrameworkInterop() <PrimeNumberCheckerDelegate> | |
@property (strong, nonatomic) PrimeNumberChecker *primeChecker; | |
@end |
This file contains 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
// AdditionFrameworkInterop.h | |
#import <Foundation/Foundation.h> | |
#import <MainSDK/MainSDK-Swift.h> | |
@interface AdditionFrameworkInterop : NSObject | |
@property (weak, nonatomic) id<InteropDelegate> delegate; | |
+ (BOOL)additionalModuleAvailable; |
This file contains 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
// Below would import or not, depending on whether it is linked | |
@import AdditionalSDK; | |
// ... | |
+ (BOOL)additionalModuleAvailable { | |
if ([AdditonalSDK class]) { // Or any class from additional SDK | |
return YES; | |
} else { | |
return NO; |
This file contains 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
// MainSDK | |
#if canImport(AdditionalSDK) | |
import AdditionalSDK | |
public class NumberInspector: PrimeNumberCheckerDelegate { | |
// ... adopt delegate protocol from AdditionalSDK | |
} | |
#else | |
public class NumberInspector { | |
// ... cannot adopt protocol from AdditionalSDK |
This file contains 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
// AdditionalSDK | |
@objc public class PrimeNumberChecker: NSObject { | |
@objc public var delegate: PrimeNumberCheckerDelegate? | |
@objc public func inspect(number: Int) { | |
// ... | |
} | |
} | |
@objc public protocol PrimeNumberCheckerDelegate { |
This file contains 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
// MainSDK | |
public class NumberInspector { | |
public weak var delegate: NumberInspectorDelegate? | |
// ... | |
public func inspect(number: Int) { | |
// perform inspection and notify delegate when done | |
} | |
} |
This file contains 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
// MyPrivateClass.m | |
#import "MyPrivateClass.h" | |
@implementation MyPrivateClass | |
@synthesize privateProperty; | |
+ (void)load { | |
// This is called once, when module is being loaded, | |
// "Invoked whenever a class or category is added to the Objective-C |
This file contains 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
... | |
@objc(Factory) | |
internal class Factory: NSObject { | |
private static var privateClassType: MyPrivateClass.Type! | |
@objc static func registerPrivateClassType(type: MyPrivateClass.Type) { | |
print("REGISTRATION CALLED WITH TYPE = \(type)") | |
privateClassType = type | |
} |
This file contains 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
protocol SomeProtocol { | |
init() | |
} | |
class SomeClass: SomeProtocol { | |
... | |
} | |
// This will work | |
let instance: SomeProtocol = SomeClass.init() |
NewerOlder