Skip to content

Commit d2a1647

Browse files
[release/7.0.1xx-xcode14-rc2] [UIKit] Change UITextInput.SelectedTextRange to not be ArgumentSemantic.Copy. Fixes #15677. (#16277)
When a property is declared as ArgumentSemantic.Copy, we'll copy the input value in property setters. Unfortunately this makes UIKit crash, because for UITextField.SelectedTextRange UIKit might use a custom UITextRange subclass, with a broken 'copy' implementation (doesn't copy all the fields), that subsequently makes the app crash. On the other hand, UITextRange doesn't conform to NSCopying, and as such is in theory not necessarily copyable, and thus I believe the bug is really that the property is declared as a 'copy' property. Fixes #15677. Backport of #16201 Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
1 parent 88043e4 commit d2a1647

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/uikit.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7254,7 +7254,9 @@ interface IUITextInput {}
72547254
interface UITextInput : UIKeyInput {
72557255
[Abstract]
72567256
[NullAllowed] // by default this property is null
7257-
[Export ("selectedTextRange", ArgumentSemantic.Copy)]
7257+
// This is declared as ArgumentSemantic.Copy, but UITextRange doesn't conform to NSCopying.
7258+
// Also declaring it as ArgumentSemantic.Copy makes UIKIt crash: https://github.com/xamarin/xamarin-macios/issues/15677
7259+
[Export ("selectedTextRange")]
72587260
UITextRange SelectedTextRange { get; set; }
72597261

72607262
[Abstract]

0 commit comments

Comments
 (0)