Skip to content

Commit 6eef7be

Browse files
committed
Support bypass mode while creating Interpose object
1 parent 199f68f commit 6eef7be

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/InterposeKit/InterposeKit.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ final public class Interpose {
7272
}
7373

7474
/// Initialize with a single object to interpose.
75-
public convenience init(_ object: NSObject, builder: ((Interpose) throws -> Void)? = nil) throws {
76-
try self.init(.strong(object), builder: builder)
75+
public convenience init(_ object: NSObject, bypass: Bool = false, builder: ((Interpose) throws -> Void)? = nil) throws {
76+
try self.init(.strong(object), bypass: bypass, builder: builder)
7777
}
7878

7979
/// Initialize with a single object to interpose.
80-
public init(_ objectContainer: AnyObjectContainer, builder: ((Interpose) throws -> Void)? = nil) throws {
80+
public init(_ objectContainer: AnyObjectContainer, bypass: Bool = false, builder: ((Interpose) throws -> Void)? = nil) throws {
8181
self.objectContainer = objectContainer
8282
self.class = type(of: objectContainer.object)
8383

8484
let object = objectContainer.object
8585

86-
if let actualClass = checkObjectPosingAsDifferentClass(object) {
86+
if !bypass, let actualClass = checkObjectPosingAsDifferentClass(object) {
8787
if isKVORuntimeGeneratedClass(actualClass) {
8888
throw InterposeError.keyValueObservationDetected(object)
8989
} else {

0 commit comments

Comments
 (0)