Post

Replies

Boosts

Views

Created

Custom paste into UITextView
I am implementing a UITextView subclass that supports the editing of structured text with block styles (e.g. paragraph, heading, list, quote etc.) and inline styles (e.g. emphasis, code etc.) I need to be able to cut, copy and paste structured text from the UITextView. Implementing this is straightforward: override cut(_:), copy(_:) and paste(_:) and read/write the structured text (a JSON format) to/from the general pasteboard. This works fine, but the UITextView's smart insert/delete behavior (see UITextInputTraits.smartInsertDeleteType), which adjusts spaces around the selection, is lost. I have explored implementing a custom text paste delegate (UITextPasteDelegate). This would appear to provide support for custom paste behaviour. I can to extract the contents of the pasteboard and transform them to an attributed string for pasting by implementing textPasteConfigurationSupporting(_:, transform:) however any custom attributes I add to the string placed in the UITextPasteItem are ignored (standard attributes are also ignored because allowsEditingTextAttributes is set to false). I can solve this issue by implementing textPasteConfigurationSupporting(_:, performPasteOf:, to:) but this breaks the smart insert/delete behaviour, even when pasting plain text. Unfortunately I can see no way to paste custom textual data into a UITextView without losing the standard smart insert/delete behaviour. Am I missing something? Any pointers on how I can achieve cut/copy/paste for a custom clipboard format while maintaining smart insert/delete would be appreciated.
0
0
1.5k
Oct ’21
How can I suppress warning that "Conversion to Swift 5 is available"?
After upgrading to Xcode 13.2 I receive a warning that "Conversion to Swift 5 is available". If I click the warning then a target conversion window appears allowing me to select which targets should be migrated. My project uses a large number of Swift packages and this list contains 76 targets. 73 of these targets are from packages that target swift-tools-version: 5 or newer. The other 3 packages have swift-tools-version set to 4.x. Unfortunately these are open-source packages that I cannot change. If I try to run the migration it stops with an error that the project could not be built, with no additional information. This is incorrect as the project and all dependencies build fine. The warning is not removed if I click "Convert Later", even if "Remind Me" is unchecked. The Swift compiler version for the top-level Xcode project is set to 5. I don't understand why I'm getting this warning as it did not appear with Xcode 13.0 or 13.1. Is there a way to suppress this warning? We have a zero warning policy for our projects so I need to resolve or suppress this warning, at least for the current Xcode version (13.x).
11
1
9.1k
Jan ’22
Custom paste into UITextView
I am implementing a UITextView subclass that supports the editing of structured text with block styles (e.g. paragraph, heading, list, quote etc.) and inline styles (e.g. emphasis, code etc.) I need to be able to cut, copy and paste structured text from the UITextView. Implementing this is straightforward: override cut(_:), copy(_:) and paste(_:) and read/write the structured text (a JSON format) to/from the general pasteboard. This works fine, but the UITextView's smart insert/delete behavior (see UITextInputTraits.smartInsertDeleteType), which adjusts spaces around the selection, is lost. I have explored implementing a custom text paste delegate (UITextPasteDelegate). This would appear to provide support for custom paste behaviour. I can to extract the contents of the pasteboard and transform them to an attributed string for pasting by implementing textPasteConfigurationSupporting(_:, transform:) however any custom attributes I add to the string placed in the UITextPasteItem are ignored (standard attributes are also ignored because allowsEditingTextAttributes is set to false). I can solve this issue by implementing textPasteConfigurationSupporting(_:, performPasteOf:, to:) but this breaks the smart insert/delete behaviour, even when pasting plain text. Unfortunately I can see no way to paste custom textual data into a UITextView without losing the standard smart insert/delete behaviour. Am I missing something? Any pointers on how I can achieve cut/copy/paste for a custom clipboard format while maintaining smart insert/delete would be appreciated.
Replies
0
Boosts
0
Views
1.5k
Activity
Oct ’21
How can I suppress warning that "Conversion to Swift 5 is available"?
After upgrading to Xcode 13.2 I receive a warning that "Conversion to Swift 5 is available". If I click the warning then a target conversion window appears allowing me to select which targets should be migrated. My project uses a large number of Swift packages and this list contains 76 targets. 73 of these targets are from packages that target swift-tools-version: 5 or newer. The other 3 packages have swift-tools-version set to 4.x. Unfortunately these are open-source packages that I cannot change. If I try to run the migration it stops with an error that the project could not be built, with no additional information. This is incorrect as the project and all dependencies build fine. The warning is not removed if I click "Convert Later", even if "Remind Me" is unchecked. The Swift compiler version for the top-level Xcode project is set to 5. I don't understand why I'm getting this warning as it did not appear with Xcode 13.0 or 13.1. Is there a way to suppress this warning? We have a zero warning policy for our projects so I need to resolve or suppress this warning, at least for the current Xcode version (13.x).
Replies
11
Boosts
1
Views
9.1k
Activity
Jan ’22