Hi, I encounter unexpected behavior from the FileWrapper updates that occurs when I remove file using FileManager.removeItem
If I first remove a file from the directory, then create NSFileWrapper instance, I get unexpected values from calls to matchesContents(of:)
import Foundation
let copyURL = URL(filePath: "/Users/marcinkrzyzanowski/Downloads/filewrappertest.test/COPY.png")
// THIS OPERATION BREAKS IT. REMOVE IT TO WORK AS EXPECTED
try! FileManager().removeItem(at: copyURL)
let dirURL = URL(filePath: "/Users/marcinkrzyzanowski/Downloads/filewrappertest.test")
let fw = try FileWrapper(url: dirURL)
fw.fileWrappers // ["IMG_0736.png"]
try FileManager.default.copyItem(at: URL(filePath: "/Users/marcinkrzyzanowski/Downloads/filewrappertest.test/IMG_0736.png"), to: copyURL)
fw.fileWrappers // ["IMG_0736.png"]
fw.matchesContents(of: dirURL) // true (expected: false)
try fw.read(from: dirURL)
fw.fileWrappers! // ["COPY.png", "IMG_0736.png"]
fw.matchesContents(of: dirURL) // true
I don't understand why the "FileManager.removeItem" affects the NSFileWrapper behavior in such a way. It does not change even when I add a delay after removeItem. Any idea?
Post
Replies
Boosts
Views
Activity
The UITextView.allowedWritingToolsResultOptions has no effect to how "Writing Tools" feature works. When it is set to empty, it still offer all options in the Writing Tools popup dialog. The result is that it is not possible to limit output results to eg. only plain text, or disable tables in output.
let textView = UITextView()
textView.isEditable = true
textView.writingToolsBehavior = .complete
textView.allowedWritingToolsResultOptions = []
resulting Writing Tools has all options available. I Tested with TextKit1 and TextKit 2 setup.
tested on iPadOS 18.1 beta (22B5069a)
Report: FB15429824
UITextView erroneously overrides string attributes when applying spellchecker annotation attributes.
It doesn't need any particular setting. Default UITextView instance with attributed text
let textView = UITextView(usingTextLayoutManager: true)
textView.spellCheckingType = .yes
Once spellcheck attributes get applied, other attributes like foreground color get applied to the misspelled words. This behavior happens only on Mac Catalyst, and started to appear on macOS 14 or newer.
Please check the Xcode project that demonstrates the issue https://github.com/user-attachments/files/16689336/TextEditor-FB14165227.zip
Open TextEditor project
Select "My Mac (Mac Catalyst)" build destination
Run the project. A window with a text area should appear
Select the whole text (either using mouse or keyboard command+a)
Observe how foregroundColor changes to text (this is the issue)
That eventually led to crash 💥
This bug is reported to Apple FB14165227
Keyboard shortcuts that use the Command key modifier are not handled properly, and the UIKeyCommand action and pressesBegan and pressesEnded methods are not called at all or are called unreliably.
It is easy to reproduce using this snippet:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let textView = MyTextView()
textView.font = UIFont.systemFont(ofSize: 24)
textView.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec efficitur eros vitae dui consectetur molestie. Integer sed massa rutrum, pharetra orci eget, molestie sem. Fusce vestibulum massa nisi, vitae viverra purus condimentum et. Sed nec turpis aliquam, tempus enim sit amet, gravida libero. Praesent scelerisque venenatis nunc, vel convallis nisl auctor vitae. Mauris malesuada tempus pharetra. Nullam ornare venenatis ullamcorper. In viverra feugiat tincidunt. Nullam iaculis urna eu semper rutrum. "
textView.isEditable = true
textView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(textView)
NSLayoutConstraint.activate([
textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
textView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
textView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
textView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])
}
}
class MyTextView: UITextView {
override var keyCommands: [UIKeyCommand]? {
[
UIKeyCommand(input: "[", modifierFlags: .command, action: #selector(commandAction(_:)))
]
}
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("pressesBegan")
super.pressesBegan(presses, with: event)
}
override func pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("pressesEnded")
super.pressesEnded(presses, with: event)
}
@objc private func commandAction(_ sender: Any?) {
print("commandAction")
}
}
Run the code in a Simulator or on a Device with an external keyboard connected. Observe the console for a string "commandAction" when pressing the combination Command + [ on the keyboard. Result it not predictable, the UIKeyCommand is not called at all, or called in a loop, or sometimes called after change selection in the UITextView. The same with pressesBegan and pressesEnded. Compare results with the change where instead of Command modifier, we use Control modifier eg.: "UIKeyCommand(input: "[", modifierFlags: .command, action: #selector(commandAction(_:))" - now each keyboard shortcut is properly reported to methods.
The UIKeyCommand.wantsPriorityOverSystemBehavior property changes nothing.
Behavior reproducible in the Simulator and on the Device (iPad)
(the issue was confirmed during online WWDC24 Labs)
Reported as FB13897415
How do I get updates about the file name change from the NSDocument window title? I noticed that despite file being property registered as a file presenter (by default), none of presentedItemDidChange, presentedSubitemDidChange, or presentedItemDidMove is called despite filename updates on the filesystem.
the presentedItemURL does update value at some point.
My subclass has autosave enabled, which makes title editing possible.
override class var autosavesInPlace: Bool {
true
}
[object Object]
The way NSTextView is built it's inevitable to use NSTextStorage with TextKit2, however the NSAttributedString uses NSRange vs the TextKit2 family uses NSTextRange for text location, etc. What I struggle with is the relation between these two. I didn't find a convenient translation between these two. Is NSAttributedStrint NSRange length=1 equal to NSTextRange offset 1? I think it's not (at least it's not necessarily true for every NSTextContentManager.
So my question is, given a NSTextRange, what is the corresponding NSRange in NSTextContentStorage.attributedString
The documentation to NSFileProviderManager.signalEnumerator(for:) says
Alerts the system to changes in the specified folder’s content.
and headers says:
Set the containerItemIdentifier to the identifier of the enumerated container that was specified in
-[NSFileProviderExtension enumeratorForContainerItemIdentifier:error:]
from that, I understand the parameter is any container identifier that returns valid NSFileProviderEnumerator.
I think I tried everything already, and it just doesn't seem to work this way. The only container that seems to work is .workingSet
I'm not sure whether it suppose to work with anything else than workingSet container, or I'm missing some important part that makes it happen. Does anyone have a sample that works with eg. rootContainer?
help. I'm loosing on this one.
I'm trying to implement custom NSTextContentManager and use it with NSTextView, however it seems that NSTextView expect NSTextContentStorage all the time.
final class MyTextContentManager: NSTextContentManager {
// ...
}
It's added to layout manager, and NSTextView instance finds it properly:
let textContentManager = MyTextContentManager() textContentManager.addTextLayoutManager(textLayoutManager)
however, when I use it, I see errors at:
[MyTextContentManager textStorage]: unrecognized selector sent to instance 0x600003d84870
the textStorage property is part of NSTextStorageObserving, that is not NSTextContentManager interface.
It looks like NSTextView is not ready to work with custom NSTextContentManager. What did I miss?
What's the purpose of NSFileProviderReplicatedExtension.item(for:request:completionHandler:) call. It seems like it duplicate what the NSFileProviderEnumerator.enumerateItems(for:startingAt:) already returned. I couldn't find where and why this method is called. What happens if it return different types than from the enumerator? Can you please point me to some explanation what is the relation between these two calls?
From Data Essentials in SwiftUI - https://developer.apple.com/wwdc20/10040 WWDC session:
you can focus on part of your app by having multiple ObservableObject that offer a specific projection onto your data model and are designed to expose just the data that is needed. I struggle to setup bindings between data model and multiple ObservableObjects as a data projection, without make Data Model a dependency. I wonder if anyone can put some light how to make this setup works. Thanks in advance.
I put my experiment in this gist - https://gist.github.com/krzyzanowskim/a58a74914397af3379d766597bdbfa76/edit - it's not working, but maybe that's a start for somebody.
Thanks in advance.
I wonder where can I find source of ShapeEdit app mentioned in the WWDC 2020 SwiftUI videos. All I can find is old ShapeEdit.
Hi,I want to install a symlink inside /usr/local/binI don't use sandbox (hardened runtime only).I tried:NSWorkspace().requestAuthorization(to: .createSymbolicLink) { (auth, error) in
let fm = FileManager(authorization: auth!)
try fm.createSymbolicLink(at: URL(fileURLWithPath: "/usr/local/bin/foo"), withDestinationURL: URL(fileURLWithPath: appBundlePath + "/Contents/MacOS/Foo"))
}it doesn't work though, I always getcom.apple.secinitd.fileoperations: xpc_pipe_routine() returned [5: Input/output error]The file couldn’t be saved.What are my options to install symlink at /usr/local/bin?
Hi,I'm trying to use CloudKit Web Services to access my public database (development env.) I can read the records, when I try to use enpoint /records/modify I always get response that CREATE operation not permitted{
"records" : [
{
"serverErrorCode" : "ACCESS_DENIED",
"recordName" : "E99612AE-34A7-482E-876E-BE2F3D063397",
"reason" : "CREATE operation not permitted"
}
]
}I have Web Token obtained as described here (Authenticating Users): https://developer.apple.com/library/prerelease/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/SettingUpWebServices/SettingUpWebServices.html#//apple_ref/doc/uid/TP40015240-CH24-SW1I already did try enable "everything" in "Security" of my "Record Type", didn't help. What should I do to make it work ? help, I'm totally stuck.