Skip to content

Commit

Permalink
🛠 Refactor: Split RNIObjectMetadata
Browse files Browse the repository at this point in the history
Summary: Extract extension in `RNIObjectMetadata` into its own file.
  • Loading branch information
dominicstop committed Apr 26, 2023
1 parent a5d2bb7 commit 17c2ce1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// RNIObjectMetadata+Default.swift
// react-native-ios-modal
//
// Created by Dominic Go on 4/27/23.
//

import Foundation

fileprivate let RNIObjectMetadataMap = NSMapTable<AnyObject, AnyObject>(
keyOptions: .weakMemory,
valueOptions: .strongMemory
);

public extension RNIObjectMetadata {
var metadata: T? {
set {
if let newValue = newValue {
RNIObjectMetadataMap.setObject(newValue, forKey: self);

} else {
RNIObjectMetadataMap.removeObject(forKey: self);
};
}
get {
RNIObjectMetadataMap.object(forKey: self) as? T
}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,8 @@

import Foundation

fileprivate let RNIObjectMetadataMap = NSMapTable<AnyObject, AnyObject>(
keyOptions: .weakMemory,
valueOptions: .strongMemory
);

public protocol RNIObjectMetadata: AnyObject {
associatedtype T: AnyObject;

var metadata: T? { get set };
};

public extension RNIObjectMetadata {
var metadata: T? {
set {
if let newValue = newValue {
RNIObjectMetadataMap.setObject(newValue, forKey: self);

} else {
RNIObjectMetadataMap.removeObject(forKey: self);
};
}
get {
RNIObjectMetadataMap.object(forKey: self) as? T
}
};
};

0 comments on commit 17c2ce1

Please sign in to comment.