Skip to content

Commit

Permalink
🐞 Fix: UniqueIdentifierSynthesizing. synthesizedStringID
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 27, 2024
1 parent 87bc0b9 commit 397a4f7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
22 changes: 22 additions & 0 deletions ios/Temp/NSObject+Helpers.swift
Original file line number Diff line number Diff line change
@@ -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;
}
};
25 changes: 18 additions & 7 deletions ios/Temp/UniqueIdentifierSynthesizing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,46 @@ 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)";
};
};


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)";
};
};

Expand Down

0 comments on commit 397a4f7

Please sign in to comment.