Post

Replies

Boosts

Views

Activity

Autosaved documents don't delete
Pertinent system prefs: [X] Ask to keep changes when closing documents [ ] Close windows when quitting an app App setup: autosavesInPlace returns true I've run my app many times and have one test doc that I use each time I run via it being automatically reopened. Recently I created a couple new documents, then closed them before quitting and used the Delete button to dispose of them. Yet each time I run, all the supposedly deleted docs reappear. They're not being deleted from "/Users//Library/Containers//Data/Library/Autosave Information/". Why?
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
903
Nov ’22
Unicode categories as seen in macOS's Emoji & Symbols palette?
The list of categories on the left (and can be customized with the … button at the top-left): Is there any API to get that list of category names and the code points they encompass? They're different than the standard Unicode code point blocks? If so, is it available on iOS? These categories don't appear to be available from any of the unicode.org documents I've seen, but then they host a ton of data, and most of it is beyond my need.
0
0
397
Apr ’23
Can no longer share files to app
I have an iOS/iPadOS app that has the ability to open files by using the Share action in the Files app. The app receives the application:openURL:options: method, but when it tries to access the given url, it produces this error: Error Domain=NSCocoaErrorDomain Code=257 "The file “Zippy.cbz” couldn’t be opened because you don’t have permission to view it." UserInfo={NSURL=file:///private/var/mobile/Containers/Shared/AppGroup/B1C0C77A-2E86-4BD7-9344-845D6DA6FA74/File%20Provider%20Storage/Zippy.cbz, NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/B1C0C77A-2E86-4BD7-9344-845D6DA6FA74/File Provider Storage/Zippy.cbz, NSUnderlyingError=0x283c6d860 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} This used to work in earlier versions of iPadOS. It's currently running 16.5.1 ©. I see "AppGroup" in the path. Does that mean that something thinks my app is using a shared app group? It's not. Does it need to now in order to receive a shared file?
0
0
671
Jul ’23
Adding ImageAnalysisInteraction from Objective-C
Is it possible to add ImageAnalysis to a UIImageView from my Objective-C app? I went through the work of adding VNRecognizeTextRequest code to analyze the image and hilite the found text rects, but was unsure how to add user interaction with the found text ranges. Then I noticed a web page that described ImageAnalysisInteraction, but it's Swift only, and I don't know how to get to that from Objective-C. I'd love to have actual text selection ranges like you get from this, along with the text actions popover, rather than just hilited rects.
0
0
612
Jul ’23
How to override Document's shouldCloseWindowController method in Swift
To me, the documentation for this method is not at all clear and needs to provide sample code. I tried searching the dev site for sample projects, but they're no longer where they lived for decades before. And where's the TextEdit sample project?! I need to override shouldCloseWindowController so I can make sure some sub-windows can be closed before closing the document's one and only window. I've done that, but then have no idea what I'm supposed to do to all the document to close. I tried this, which is what I think the NSDocument version header says to do: if ((self.windowControllers.first?.shouldCloseDocument) != nil){ self.canClose(withDelegate:delegate as Any, shouldClose:shouldCloseSelector, contextInfo:contextInfo); } But the document never gets the close() method called - only the window goes away.
0
0
787
Mar ’24
Need advice for closing subwindows when closing main document window
I have a document class that makes a main window for showing the data. Pieces of that data can be opened in separate subwindows for editing. When the user closes the main window and the document is dirty and the subwindows are dirty, I would like to present UI that asks the user if they want to save the changes in the subwindows (and possibly the main window if I decide to turn off autoSavesInPlace for the document). I've tried a number of possible methods of doing this, but always run into some roadblock: -Overriding shouldCloseWindowController:delegate:shouldCloseSelector:contextInfo: where I would go through the open subwindows and asking and tell them to do their own UI for asking if they should be saved. This is no good because everything returns back to the run loop and the doc would close, leaving the subwindows open with their Save? sheets up. -Making the subwindows inherit from NSEditor and registering them with the document. This looked like it would work, but it caused an infinite loop in my override of commitEditingWithDelegate:didCommitSelector:contextInfo: that I don't understand. I'm probably calling the didCommitSelector wrong because the docs aren't clear and provide no example. -Adding each subwindow's NSWindowController to the document's windowControllers list. I don't recall the problems this caused. Any sage advice about this? Possible examples? The Document is Swift, the subwindows are Cocoa, so examples in either language is fine.
1
0
756
Mar ’24
Any way to make NSWorkspace's showSearchResultsForQueryString work?
It fails in a sandboxed app. I found a couple suggestions. One was to add a NSAppleEventsUsageDescription pair to the Info.plist so the user would be asked to grant permission for AppleEvents. But that never happens for showSearchResultsForQueryString. The next was to add the com.apple.security.temporary-exception.apple-events entitlement and provide com.apple.finder as the app. This DOES work, but Apple is rejecting my app because of it, even though I've said it's the only way to make showSearchResultsForQueryString work. I'm still waiting for them to tell me how to do it in a more correct way. This is obviously a bug, because an app should be able to use any NSWorkspace method without jumping through security hoops. Has anyone else found a way to make it work and get their app on the App Store?
7
0
1.2k
Jul ’24
How does NSFetchRequest compare custom objects?
I have a CoreData-based app that's many years old, so it's been a long time since I've actually dealt with CoreData. Over recent years, I've noticed that fetch requests aren't finding the object I know is in there. The entity is called Folder and has a single attribute named url, which is of type Transformable. The transformer is a custom one that converts a url into a dictionary with 2 keys; one is a security scoped bookmark created from the url, and the other is the original url in case the bookmark fails. The dictionary is then converted to NSData using NSKeyedArchiver securely. The reverseTransformedValue does the opposite; unarchives the data to a dict, attempts to resolve the bookmark back into the url. The fetch request is set up to fetch all Folder objects where: Custom Predicate: url == $THE_URL So is the fetch request comparing the NSData that's stored in the file and comparing that to $THE_URL after running it through the transformer to arrive at an NSData, or is it running each one through the transformer to get the underlying url and comparing those with $THE_URL? Could there be a better way to compare urls in Core Data, when the app is sandboxed and must use security scoped bookmarks?
0
0
470
Jul ’24
How to return a UIMenu for read-only UITextView
I have a UITextView being added at runtime to a UIImageView as the result of doing text recognition. It's set to be editable = NO and selectable = YES. When I set the text and select it, it asks the delegate for the menu to display via: textView:editMenuForTextInRange:suggestedActions: The suggested items contains many UIAction and UICommand objects that have private methods or do not have the destructive attribute set, yet they are destructive. Some of these are: promptForReplace: transliterateChinese: _insertDrawing: _showTextFormattingOptions: I need to return a menu that has only non-destructive commands in it. First, why isn't UITextView sending only non-destructive suggested commands when its editable is NO? Second, how can I filter the array of suggested commands when it's impossible to know if they're destructive (as some are missing that attribute)? In addition to that, even non-destructive commands are causing an unrecognized selector exception, such as the Speak command, which it is sending to my view controller instead of to the UITextView, which is the only thing that knows what the text is that it should speak.
Topic: UI Frameworks SubTopic: UIKit
0
0
287
Feb ’25
Why do random errOSAInternalTableOverflow errors return when running AppleScripts via ScriptingBridge?
We have an app that controls InDesign Desktop and InDesignServer via hundreds of AppleScripts. Some macOS security updates a while back dictated that we start communicating with other apps via ScriptingBridge. We couldn't afford to convert the hundreds of AppleScripts into direct ScriptingBridge nomenclature, so we opted to keep them as is and instead tell the external apps to: [app doScript:<the script text> language:InDesignScLgApplescriptLanguage withArguments:nil undoMode:InDesignESUMScriptRequest undoName:@"blah"] There are a handful of scripts that we did convert to direct ScriptingBridge. There are times (and under the right circumstances, it's repeatable) when a certain script will have run perfectly dozens of times, and then it will throw errOSAInternalTableOverflow. We create a new SBApplication for every job (which could be a single instance of Desktop or the multiple instances of Server). Why is this error happening seemingly randomly? Is there anything we can do to work around or prevent this?
8
0
503
Apr ’26
AVAudioEngine startAndReturnError is now failing
I have a keyboard in my iOS Morse Code app that has always been able to play audio via AVAudioEngine. Recently it has been failing to produce audio. I see that startAndReturnError: is now failing with this error: Error Domain=com.apple.coreaudio.avfaudio Code=268435459 "(null)" UserInfo={failed call=err = PerformCommand(*outputNode, kAUInitialize, NULL, 0)} What's going on? Have keyboards lost the ability to play audio? Here's how I set things up: _engine = [AVAudioEngine new]; _prefs = [[NSUserDefaults alloc] initWithSuiteName:kSharedAppGroupID]; AVAudioMixerNode* mainMixerNode = _engine.mainMixerNode; AVAudioOutputNode* outputNode = _engine.outputNode; AVAudioFormat* format = [outputNode inputFormatForBus:0]; AVAudioFormat* inputFormat = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32 sampleRate:44100 channels:1 interleaved:NO]; self.srcNode = [[AVAudioSourceNode alloc] initWithRenderBlock:^OSStatus(BOOL* _Nonnull isSilence, const AudioTimeStamp* _Nonnull timestamp, AVAudioFrameCount frameCount, AudioBufferList* _Nonnull outputData) { // This block builds the data, but is never called, so it is not the culprit. }]; [_engine attachNode:self.srcNode]; [_engine connect:self.srcNode to:mainMixerNode format:inputFormat]; [_engine connect:mainMixerNode to:_engine.outputNode format:nil]; [_engine prepare];
0
0
121
1w
How to find iOS's Show Lowercase Keys value
In the iOS system prefs->Accessibility->Keyboards, there's the switch for "Show Lowercase Keys", which allows keyboards to show upper- and lower-case key caps. I can't find any mention of an accessor for that value. It doesn't show in NSUserDefaults when I dump them, nor does any header mention it. I'd like to be able to use it in my custom keyboard extension.
3
0
886
Apr ’23
NSUserDefaults for app group suite fails to write from keyboard extension
I have an iOS app which contains a custom keyboard that can be used by any app. They share a few prefs by using an app group and a named suite of NSUserDefaults. Each target (app, keyboard) keep their own instance of the shared prefs by storing it in a property: self.sharedPrefs = [[NSUserDefaults alloc] initWithSuiteName:kPrefsSuiteName]; And then add observers for a couple different prefs: [self.sharedPrefs addObserver:self forKeyPath:kPrefRecents options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; When running in the Simulator, both the app and keyboard can write to the shared prefs and both target's observers correctly respond to changes. But when running on a device (iPhone X, iPad Pro 11"), the app can write to the prefs, but the keyboard fails with: 2023-04-17 14:20:20.095600-0500 projectname[561:23591] [User Defaults] Couldn't write values for keys ( Recents ) in CFPrefsPlistSource<0x2807dc500> (Domain: group.com.my.key, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access I also noticed this when the app adds its first key value observer to the shared prefs: 2023-04-17 14:57:36.610366-0500 projectname[820:45796] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x280bc1c80> (Domain: group.com.my.key, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd This is supposed to work. What's wrong here?
1
0
1.1k
Apr ’23
Xcode 14.2 crashing in Distribute App and Validate App
After picking Automatic code signing, it will crash while packaging the app. Anybody else?
Replies
1
Boosts
0
Views
1.1k
Activity
Jan ’23
Autosaved documents don't delete
Pertinent system prefs: [X] Ask to keep changes when closing documents [ ] Close windows when quitting an app App setup: autosavesInPlace returns true I've run my app many times and have one test doc that I use each time I run via it being automatically reopened. Recently I created a couple new documents, then closed them before quitting and used the Delete button to dispose of them. Yet each time I run, all the supposedly deleted docs reappear. They're not being deleted from "/Users//Library/Containers//Data/Library/Autosave Information/". Why?
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
1
Boosts
0
Views
903
Activity
Nov ’22
Unicode categories as seen in macOS's Emoji & Symbols palette?
The list of categories on the left (and can be customized with the … button at the top-left): Is there any API to get that list of category names and the code points they encompass? They're different than the standard Unicode code point blocks? If so, is it available on iOS? These categories don't appear to be available from any of the unicode.org documents I've seen, but then they host a ton of data, and most of it is beyond my need.
Replies
0
Boosts
0
Views
397
Activity
Apr ’23
Can no longer share files to app
I have an iOS/iPadOS app that has the ability to open files by using the Share action in the Files app. The app receives the application:openURL:options: method, but when it tries to access the given url, it produces this error: Error Domain=NSCocoaErrorDomain Code=257 "The file “Zippy.cbz” couldn’t be opened because you don’t have permission to view it." UserInfo={NSURL=file:///private/var/mobile/Containers/Shared/AppGroup/B1C0C77A-2E86-4BD7-9344-845D6DA6FA74/File%20Provider%20Storage/Zippy.cbz, NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/B1C0C77A-2E86-4BD7-9344-845D6DA6FA74/File Provider Storage/Zippy.cbz, NSUnderlyingError=0x283c6d860 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} This used to work in earlier versions of iPadOS. It's currently running 16.5.1 ©. I see "AppGroup" in the path. Does that mean that something thinks my app is using a shared app group? It's not. Does it need to now in order to receive a shared file?
Replies
0
Boosts
0
Views
671
Activity
Jul ’23
Adding ImageAnalysisInteraction from Objective-C
Is it possible to add ImageAnalysis to a UIImageView from my Objective-C app? I went through the work of adding VNRecognizeTextRequest code to analyze the image and hilite the found text rects, but was unsure how to add user interaction with the found text ranges. Then I noticed a web page that described ImageAnalysisInteraction, but it's Swift only, and I don't know how to get to that from Objective-C. I'd love to have actual text selection ranges like you get from this, along with the text actions popover, rather than just hilited rects.
Replies
0
Boosts
0
Views
612
Activity
Jul ’23
Get notified when closing window containing SwiftUI view
I'm opening a new window and setting its contentView to an NSHostingView, to which I give my SwiftUI view. This view can edit certain things, and I want to be able to ask the user if they want to save their changes when they close the window. How can this be accomplished?
Replies
0
Boosts
0
Views
476
Activity
Mar ’24
How to override Document's shouldCloseWindowController method in Swift
To me, the documentation for this method is not at all clear and needs to provide sample code. I tried searching the dev site for sample projects, but they're no longer where they lived for decades before. And where's the TextEdit sample project?! I need to override shouldCloseWindowController so I can make sure some sub-windows can be closed before closing the document's one and only window. I've done that, but then have no idea what I'm supposed to do to all the document to close. I tried this, which is what I think the NSDocument version header says to do: if ((self.windowControllers.first?.shouldCloseDocument) != nil){ self.canClose(withDelegate:delegate as Any, shouldClose:shouldCloseSelector, contextInfo:contextInfo); } But the document never gets the close() method called - only the window goes away.
Replies
0
Boosts
0
Views
787
Activity
Mar ’24
Need advice for closing subwindows when closing main document window
I have a document class that makes a main window for showing the data. Pieces of that data can be opened in separate subwindows for editing. When the user closes the main window and the document is dirty and the subwindows are dirty, I would like to present UI that asks the user if they want to save the changes in the subwindows (and possibly the main window if I decide to turn off autoSavesInPlace for the document). I've tried a number of possible methods of doing this, but always run into some roadblock: -Overriding shouldCloseWindowController:delegate:shouldCloseSelector:contextInfo: where I would go through the open subwindows and asking and tell them to do their own UI for asking if they should be saved. This is no good because everything returns back to the run loop and the doc would close, leaving the subwindows open with their Save? sheets up. -Making the subwindows inherit from NSEditor and registering them with the document. This looked like it would work, but it caused an infinite loop in my override of commitEditingWithDelegate:didCommitSelector:contextInfo: that I don't understand. I'm probably calling the didCommitSelector wrong because the docs aren't clear and provide no example. -Adding each subwindow's NSWindowController to the document's windowControllers list. I don't recall the problems this caused. Any sage advice about this? Possible examples? The Document is Swift, the subwindows are Cocoa, so examples in either language is fine.
Replies
1
Boosts
0
Views
756
Activity
Mar ’24
Any way to make NSWorkspace's showSearchResultsForQueryString work?
It fails in a sandboxed app. I found a couple suggestions. One was to add a NSAppleEventsUsageDescription pair to the Info.plist so the user would be asked to grant permission for AppleEvents. But that never happens for showSearchResultsForQueryString. The next was to add the com.apple.security.temporary-exception.apple-events entitlement and provide com.apple.finder as the app. This DOES work, but Apple is rejecting my app because of it, even though I've said it's the only way to make showSearchResultsForQueryString work. I'm still waiting for them to tell me how to do it in a more correct way. This is obviously a bug, because an app should be able to use any NSWorkspace method without jumping through security hoops. Has anyone else found a way to make it work and get their app on the App Store?
Replies
7
Boosts
0
Views
1.2k
Activity
Jul ’24
How does NSFetchRequest compare custom objects?
I have a CoreData-based app that's many years old, so it's been a long time since I've actually dealt with CoreData. Over recent years, I've noticed that fetch requests aren't finding the object I know is in there. The entity is called Folder and has a single attribute named url, which is of type Transformable. The transformer is a custom one that converts a url into a dictionary with 2 keys; one is a security scoped bookmark created from the url, and the other is the original url in case the bookmark fails. The dictionary is then converted to NSData using NSKeyedArchiver securely. The reverseTransformedValue does the opposite; unarchives the data to a dict, attempts to resolve the bookmark back into the url. The fetch request is set up to fetch all Folder objects where: Custom Predicate: url == $THE_URL So is the fetch request comparing the NSData that's stored in the file and comparing that to $THE_URL after running it through the transformer to arrive at an NSData, or is it running each one through the transformer to get the underlying url and comparing those with $THE_URL? Could there be a better way to compare urls in Core Data, when the app is sandboxed and must use security scoped bookmarks?
Replies
0
Boosts
0
Views
470
Activity
Jul ’24
How to return a UIMenu for read-only UITextView
I have a UITextView being added at runtime to a UIImageView as the result of doing text recognition. It's set to be editable = NO and selectable = YES. When I set the text and select it, it asks the delegate for the menu to display via: textView:editMenuForTextInRange:suggestedActions: The suggested items contains many UIAction and UICommand objects that have private methods or do not have the destructive attribute set, yet they are destructive. Some of these are: promptForReplace: transliterateChinese: _insertDrawing: _showTextFormattingOptions: I need to return a menu that has only non-destructive commands in it. First, why isn't UITextView sending only non-destructive suggested commands when its editable is NO? Second, how can I filter the array of suggested commands when it's impossible to know if they're destructive (as some are missing that attribute)? In addition to that, even non-destructive commands are causing an unrecognized selector exception, such as the Speak command, which it is sending to my view controller instead of to the UITextView, which is the only thing that knows what the text is that it should speak.
Topic: UI Frameworks SubTopic: UIKit
Replies
0
Boosts
0
Views
287
Activity
Feb ’25
Why do random errOSAInternalTableOverflow errors return when running AppleScripts via ScriptingBridge?
We have an app that controls InDesign Desktop and InDesignServer via hundreds of AppleScripts. Some macOS security updates a while back dictated that we start communicating with other apps via ScriptingBridge. We couldn't afford to convert the hundreds of AppleScripts into direct ScriptingBridge nomenclature, so we opted to keep them as is and instead tell the external apps to: [app doScript:<the script text> language:InDesignScLgApplescriptLanguage withArguments:nil undoMode:InDesignESUMScriptRequest undoName:@"blah"] There are a handful of scripts that we did convert to direct ScriptingBridge. There are times (and under the right circumstances, it's repeatable) when a certain script will have run perfectly dozens of times, and then it will throw errOSAInternalTableOverflow. We create a new SBApplication for every job (which could be a single instance of Desktop or the multiple instances of Server). Why is this error happening seemingly randomly? Is there anything we can do to work around or prevent this?
Replies
8
Boosts
0
Views
503
Activity
Apr ’26
AVAudioEngine startAndReturnError is now failing
I have a keyboard in my iOS Morse Code app that has always been able to play audio via AVAudioEngine. Recently it has been failing to produce audio. I see that startAndReturnError: is now failing with this error: Error Domain=com.apple.coreaudio.avfaudio Code=268435459 "(null)" UserInfo={failed call=err = PerformCommand(*outputNode, kAUInitialize, NULL, 0)} What's going on? Have keyboards lost the ability to play audio? Here's how I set things up: _engine = [AVAudioEngine new]; _prefs = [[NSUserDefaults alloc] initWithSuiteName:kSharedAppGroupID]; AVAudioMixerNode* mainMixerNode = _engine.mainMixerNode; AVAudioOutputNode* outputNode = _engine.outputNode; AVAudioFormat* format = [outputNode inputFormatForBus:0]; AVAudioFormat* inputFormat = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32 sampleRate:44100 channels:1 interleaved:NO]; self.srcNode = [[AVAudioSourceNode alloc] initWithRenderBlock:^OSStatus(BOOL* _Nonnull isSilence, const AudioTimeStamp* _Nonnull timestamp, AVAudioFrameCount frameCount, AudioBufferList* _Nonnull outputData) { // This block builds the data, but is never called, so it is not the culprit. }]; [_engine attachNode:self.srcNode]; [_engine connect:self.srcNode to:mainMixerNode format:inputFormat]; [_engine connect:mainMixerNode to:_engine.outputNode format:nil]; [_engine prepare];
Replies
0
Boosts
0
Views
121
Activity
1w
How to find iOS's Show Lowercase Keys value
In the iOS system prefs->Accessibility->Keyboards, there's the switch for "Show Lowercase Keys", which allows keyboards to show upper- and lower-case key caps. I can't find any mention of an accessor for that value. It doesn't show in NSUserDefaults when I dump them, nor does any header mention it. I'd like to be able to use it in my custom keyboard extension.
Replies
3
Boosts
0
Views
886
Activity
Apr ’23
NSUserDefaults for app group suite fails to write from keyboard extension
I have an iOS app which contains a custom keyboard that can be used by any app. They share a few prefs by using an app group and a named suite of NSUserDefaults. Each target (app, keyboard) keep their own instance of the shared prefs by storing it in a property: self.sharedPrefs = [[NSUserDefaults alloc] initWithSuiteName:kPrefsSuiteName]; And then add observers for a couple different prefs: [self.sharedPrefs addObserver:self forKeyPath:kPrefRecents options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; When running in the Simulator, both the app and keyboard can write to the shared prefs and both target's observers correctly respond to changes. But when running on a device (iPhone X, iPad Pro 11"), the app can write to the prefs, but the keyboard fails with: 2023-04-17 14:20:20.095600-0500 projectname[561:23591] [User Defaults] Couldn't write values for keys ( Recents ) in CFPrefsPlistSource<0x2807dc500> (Domain: group.com.my.key, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access I also noticed this when the app adds its first key value observer to the shared prefs: 2023-04-17 14:57:36.610366-0500 projectname[820:45796] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x280bc1c80> (Domain: group.com.my.key, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd This is supposed to work. What's wrong here?
Replies
1
Boosts
0
Views
1.1k
Activity
Apr ’23