Post

Replies

Boosts

Views

Activity

Spelling/grammar check settings persistence in UITextView on Mac Catalyst
In our Mac Catalyst app running on macOS, the Edit > Spelling and Grammar > Check Spelling While Typing, Check Grammar With Spelling, and Correct Spelling Automatically preferences are reset with each opening of a new text view. How can we make those preferences persistent? Ie, when someone changes those settings for our app's text view, other incarnations of our app's text views should respect the latest preferences. We looked at swizzling NSTextView's toggleAutomaticSpellingCorrection:, saving those to NSUserDefaults, and then reading those preferences when we set up our UITextView subclass, and then setting the UITextInputTraits properties accordingly. However, our approach felt heavy handed, and I'm wondering if we are missing some out-of-the-box functionality that will make those preferences intuitively persistent. Does anyone have any suggestions? Thank you.
0
0
226
May ’24
UITextView Mac Catalyst Selected Text Replacement Bug
Starting with the macOS version 14.x.x and TextKit1, selecting multiple lines of text triggers a text replacement bug: some of the text on one of the selected lines inadvertently replaces a portion of the selected text. For example, the bug is exhibited when selecting the following lines: Carnaroli, Maratelli, or Vialone Nano are best Vialone Nano cooks quickly – watch it! It also absorbs condiments nicely. Avoid Baldo, Originario, Ribe and Roma To trigger the bug, select the three line paragraph using either the cursor or shift with arrow keys. Notice that a portion of the selected text was replaced. Command-Z to undo will allow you to repeat the undesired behavior. In this case, "e Nano cooks quickly - " is replaced by "Baldo, Originario, Ribe." This does not occur with all strings or selected strings, but in cases where it does occur, it is perfectly reproducible. It does not occur on iOS. Pasteboard contents are irrelevant. After triggering the bug repeatedly, at some point it stops occurring. Why does this bug occur? How can it be fixed? Here is some sample code to reproduce the issue. @end @implementation TestNoteViewController - (void)viewDidLoad { [super viewDidLoad]; [self createTextView]; } - (void)createTextView { NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:self.note.text attributes:nil]; NSTextStorage *textStorage = [NSTextStorage new]; [textStorage appendAttributedString:attrString]; CGRect newTextViewRect = self.view.bounds; // Create the layout manager NSLayoutManager *layoutManager = [NSLayoutManager new]; [textStorage addLayoutManager:layoutManager]; // Create a text container NSTextContainer *container = [[NSTextContainer alloc] initWithSize:CGSizeMake(newTextViewRect.size.width, CGFLOAT_MAX)]; [layoutManager addTextContainer:container]; // Create and place a text view UITextView *textView = [[UITextView alloc] initWithFrame:newTextViewRect textContainer:container]; [self.view addSubview:textView]; textView.translatesAutoresizingMaskIntoConstraints = NO; UILayoutGuide *safeArea = textView.superview.safeAreaLayoutGuide; [textView.leadingAnchor constraintEqualToAnchor:safeArea.leadingAnchor].active = YES; [textView.trailingAnchor constraintEqualToAnchor:safeArea.trailingAnchor].active = YES; [textView.topAnchor constraintEqualToAnchor:safeArea.topAnchor].active = YES; [textView.bottomAnchor constraintEqualToAnchor:textView.superview.bottomAnchor].active = YES; } @end
0
0
320
Apr ’24
CKNotificationInfo's desiredKeys with CKDatabaseSubscription
Is it possible to use the CKNotificationInfo's desiredKeys property for the CKDatabaseSubscription? I'd like to use have access to those values in the AppDelegate function... application:didReceiveRemoteNotification:fetchCompletionHandler: When I try to create subscriptions with desiredKeys, I get an error reading "cannot add additionalFields to this subscription type." Is that for real? Can we not use desiredKeys with CKDatabaseSubscriptions?
0
0
667
Feb ’21
CloudKit Dashboard: Deploy to Production deleting Subscription Types
In attempting to deploy changes made in the development environment to the production environment, the confirmation dialogue shows that all Subscription Types are set to be deleted. Why? The Subscription Types are present in the development environment, and there appears to be no way to prevent deletion of the Subscription Types when deploying to production. As you might imagine, I'm worried deploying our changes will break cloud sync for everyone using our apps by invalidating subscriptions. What's going on here? How can I ensure that CloudKit subscriptions continue to work?
1
0
898
Feb ’21
In WidgetKit with dynamic data, how to specify the default IntentConfiguration for new widgets?
The desirable example is exhibited by the Apple Notes widgets. When adding an Apple Notes widget, WidgetKit goes ahead and assigns an IntentConfiguration to the new widget. You can see this by editing the widget and noticing that the selection element does not read "Choose" but instead includes the name of the note or folder that was automatically selected as default for the new widget. You'll also notice that this placeholder widget's data source does not change from one source to another – the assigned IntentConfiguration is respected. How can we do this in our Widgets? It should look like this: someone creates a new widget, we use their most recent data item for the placeholder, and that item is 1) persisted in the Widget until they change it 2) reflected in the edit widget dialogue.
0
0
652
Sep ’20
CloudKit Notifications With Mac Catalyst
Sync between iOS and Mac Catalyst is intermitent. The fundamental issue is slow and inconsistent remote notifications being sent to and received by the Mac Catalyst app.When making changes in the Mac Catalyst app, those changes are successfully pushed to the iCloud private database and the iOS or iPadOS app successfully receives the remote notification indicating the change. In short, the MacOS -> iOS direction is seemless. When making changes in the other direction, we run into problems. A change in the iOS app successfully gets pushed up to the iCloud private database, and other iOS or iPadOS devices successfully receive the remote notification. However, Mac Catalyst apps most commonly will not receive the remote notification at all, or – occassionally – will receive it several minutes after the change took place. Rarely will the Mac Catalyst app receive the notification in a timeframe consistent with the performance of iOS apps (within 2-4 seconds).Why are Mac Catalyst apps having so much trouble receiving these CloudKit-triggered remote notifications? (Note that these issues are present in both development and production environments.)
20
1
5k
Oct ’19