diff --git a/ios/Temp/NSObject+Helpers.swift b/ios/Temp/NSObject+Helpers.swift new file mode 100644 index 00000000..fc1da37e --- /dev/null +++ b/ios/Temp/NSObject+Helpers.swift @@ -0,0 +1,22 @@ +// +// NSObject+Helpers.swift +// react-native-ios-modal +// +// Created by Dominic Go on 9/27/24. +// + +import Foundation + + +public extension NSObject { + var classNameTruncated: String { + let fullClassName = self.className; + let classNameComponents = fullClassName.components(separatedBy: "."); + + guard let className = classNameComponents.last else { + return fullClassName; + }; + + return className; + } +}; diff --git a/ios/Temp/UniqueIdentifierSynthesizing.swift b/ios/Temp/UniqueIdentifierSynthesizing.swift index 5e884d1e..103ac891 100644 --- a/ios/Temp/UniqueIdentifierSynthesizing.swift +++ b/ios/Temp/UniqueIdentifierSynthesizing.swift @@ -21,15 +21,15 @@ public protocol UniqueIdentifierSynthesizing: AnyObject { public extension UniqueIdentifierSynthesizing where Self: NSObject { var synthesizedStringID: String { - "\(self.className)-\(self.synthesizedIntID)"; + "\(self.classNameTruncated)-\(self.synthesizedIntID)"; }; var synthesizedLongStringID: String { - "\(self.className)-\(self.synthesizedUUID)"; + "\(self.classNameTruncated)-\(self.synthesizedUUID)"; }; var synthesizedVeryLongStringID: String { - "\(self.className)-\(self.synthesizedIntID)-\(self.synthesizedUUID)"; + "\(self.classNameTruncated)-\(self.synthesizedIntID)-\(self.synthesizedUUID)"; }; }; @@ -37,19 +37,30 @@ public extension UniqueIdentifierSynthesizing where Self: NSObject { public extension UniqueIdentifierSynthesizing where Self: AnyObject { fileprivate var className: String { - String(describing: type(of: self)); + return String(describing: type(of: self)); + }; + + fileprivate var classNameTruncated: String { + let fullClassName = self.className; + let classNameComponents = fullClassName.components(separatedBy: "."); + + guard let className = classNameComponents.last else { + return fullClassName; + }; + + return className; }; var synthesizedStringID: String { - "\(self.className)-\(self.synthesizedIntID)"; + "\(self.classNameTruncated)-\(self.synthesizedIntID)"; }; var synthesizedLongStringID: String { - "\(self.className)-\(self.synthesizedUUID)"; + "\(self.classNameTruncated)-\(self.synthesizedUUID)"; }; var synthesizedVeryLongStringID: String { - "\(self.className)-\(self.synthesizedIntID)-\(self.synthesizedUUID)"; + "\(self.classNameTruncated)-\(self.synthesizedIntID)-\(self.synthesizedUUID)"; }; };