The documentation for getRelationship says: “For example, to discover if a file is contained by a Trash directory, call [fileManager getRelationship:&result ofDirectory:NSTrashDirectory inDomain:0 toItemAtURL:url error:&error].” However, I can’t get the following Swift code to work:
var relationship: URLRelationship = .contains
getRelationship(&relationship, of: .trashDirectory,
in: SearchPathDomainMask(rawValue: 0),
toItemAt: url)
After finding your comment above, I tried using url(for:in:appropriateFor:create:) to get the trash directory, but can’t get that to work either (iOS 14.0.1, Xcode 12.0.1). The following code always fails with "The requested operation couldn’t be completed because the feature is not supported.":
let fileManager = FileManager.default
let docURL = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first!
do {
let trashURL = try fileManager.url(for: .trashDirectory, in: .userDomainMask,
appropriateFor: docURL, create: false)
print("trashURL = \(trashURL)")
}
catch {
print("could not get trashURL: \(error.localizedDescription)")
}
Is this API not working, or am I doing something wrong? Thanks!
Post
Replies
Boosts
Views
Activity
Workaround from @JPEGuin on Twitter: use 'var content = UIListContentConfiguration.sidebarCell()' instead of defaultContentConfiguration().
I get the same 'Unknown style: 10' crash in my UISplitViewController-based app (with sidebar) after upgrading my iPad to beta 4. Doesn't depend on the Xcode version, happens with Xcode 12 beta 3 as well as beta 4.
How do you get this to work for a UIBarButtonItem (which is not a UIControl)? If I set a primaryAction or set action/target, I lose the immediate popup of the menu.
The code using explicit ToolbarItemPlacement puts the controls in the right place at first, but after tapping on the Add button, the Edit button disappears. This only happens when placing it using .navigationBarLeading, not when placing it with .navigationBarTrailing. Any ideas on how to address this?