-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Extract extension in `RNIObjectMetadata` into its own file.
- Loading branch information
1 parent
a5d2bb7
commit 17c2ce1
Showing
2 changed files
with
29 additions
and
21 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
ios/src_library/React Native/RNIObjectMetadata/RNIObjectMetadata+Default.swift
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
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 | ||
} | ||
}; | ||
}; |
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