Skip to content

Commit eb521b5

Browse files
committed
refactor: improve private field access logic in MarkdownTextInputDecoratorComponentView
1 parent c556257 commit eb521b5

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

apple/MarkdownTextInputDecoratorComponentView.mm

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,16 @@ - (void)addTextInputObservers
101101
[_markdownTextFieldObserver textFieldDidChange:_textField];
102102

103103
if (@available(iOS 16.0, *)) {
104-
std::string text = "txet";
105-
std::reverse(text.begin(), text.end());
106-
NSTextStorage *textStorage = [_textField valueForKey:[NSString stringWithFormat:@"%sStorage", text.c_str()]];
107-
NSTextContainer *textContainer = [_textField valueForKey:[NSString stringWithFormat:@"%sContainer", text.c_str()]];
108-
NSTextLayoutManager *textLayoutManager = [textContainer valueForKey:[NSString stringWithFormat:@"%sLayoutManager", text.c_str()]];
109-
104+
auto key = [](std::string s) {
105+
std::reverse(s.begin(), s.end());
106+
return @(s.c_str());
107+
};
108+
109+
NSTextContainer *textContainer = [_textField valueForKey:key("reniatnoCtxet_")];
110+
NSTextLayoutManager *textLayoutManager = [textContainer valueForKey:key("reganaMtuoyaLtxet_")];
111+
110112
_markdownTextLayoutManagerDelegate = [[MarkdownTextLayoutManagerDelegate alloc] init];
111-
_markdownTextLayoutManagerDelegate.textStorage = textStorage;
113+
_markdownTextLayoutManagerDelegate.textStorage = [_textField valueForKey:key("egarotStxet_")];
112114
_markdownTextLayoutManagerDelegate.markdownUtils = _markdownUtils;
113115
textLayoutManager.delegate = _markdownTextLayoutManagerDelegate;
114116
}

0 commit comments

Comments
 (0)