I can't get my drag and drop with DataRepresentation to work with Transferable. I'm trying to drag and drop instances of DataSettings which is an NSManagedObject that conforms to NSSecureCoding.
Here's my UTType:
extension UTType {
static var encoderSettings = UTType(exportedAs: "com.simulator.EncoderSettings")
}
Here's my conformance to Transferable:
extension DataSettings: Transferable {
var data: Data? {
try? NSKeyedArchiver.archivedData(withRootObject: self, requiringSecureCoding: true)
}
public static var transferRepresentation: some TransferRepresentation {
/*DataRepresentation(contentType: .commaSeparatedText) { setting in
let data = setting.data
print("DataRepresentation: \(data)")
return data!
} importing: { data in
print("data: \(data)")
return DataSettings()
}*/
DataRepresentation(contentType: .encoderSettings) { setting in
let data = setting.data
print("DataRepresentation: \(data)")
return data!
} importing: { data in
print("data: \(data)")
return DataSettings()
}
// ProxyRepresentation(exporting: \.title)
}
}
Here's a view where I'm testing my drop destination:
struct DropTest: View {
@State var isDropTargeted = false
var body: some View {
Color.pink
.frame(width: 200, height: 200)
.dropDestination(for: EncoderSettings.self) { setting, location in
print("\(setting)")
return true
} isTargeted: {
isDropTargeted = $0
print("Got it!!!")
}
}
}
Here's my Info plist:
The ProxyRepresentation (String) works but I need the actual Data.
The dragging starts (i.e.: I can drag the view that has the .draggable with DataSettings) but I can't drop it on my DropTest view. I can drop it on a view or app that accepts the ProxyRepresentation.
What am I missing?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
My AppIntents were showing in the Shortcuts app. Now they don't. If I try to create a shortcut my app doesn't show in the list of apps that have shortcuts.
I have no compile or linking errors. I'm using Xcode 14.1.
My app is UIKit based though it has lots of SwiftUI.
Any ideas on how to resolve this would be greatly appreciated.
My app is mostly implemented in UIKit. Will AppIntents work with UIKit? If so, which (scene or app) delegate method gets called to start the intent?
My iPad app supports features such Copy (cmd-C) and Paste (cmd-V). How can I get these to show in the Edit menu when I hold down the Command key?
Undo (cmd-Z) and Redo (shift-cmd-Z) show perfectly. Looks like the system internally looks at UndoManager. Same with Hide Sidebar: system detected presence of Sidebar and is showing the keyboard shortcut to hide it.
Ramon.
How does one change the width of the primary column? I’ve tried preferredPrimaryColumnWidthFraction when the svc is intantiated but it has no effect. I’m using .doubleColumn style for the svc and my primary view controller is using .sidebar appearance style.
Is there a way to detect when the sidebar is hidden by touching the display mode button? I'm looking for a didHide version of:
splitViewController(_ svc: UISplitViewController, willHide column: UISplitViewController.Column)
I'm getting Xcode compiler error when trying to subclass UIContextMenuConfiguration.
Here's simple code that reproduces the problem:
@available(iOS 13.0, *)
class DateDifferenceContextMenu: UIContextMenuConfiguration {
		init(indexPath: IndexPath, dateDifference: Int) {
				super.init(identifier: nil, previewProvider: nil, actionProvider: nil)
		}
}
The error reads:
Must call a designated initializer of the superclass 'UIContextMenuConfiguration'. My super call matches the designated initializer. What's wrong?
I'm creating a new scene like:
UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil/*options*/) { error in
dPrint("\(error)")
}
The activity parameter has userInfo that I need in the new scene; for example,
activity.userInfo = ["sampleKey":"sampleData"]
Here's how I'm creating the new scene:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = ContainerViewController(to: createSplitViewController())
window?.makeKeyAndVisible()
scene.title = SystemData.appName
if appDelegate.isOnboardingNeeded, let containerController = window?.rootViewController as? ContainerViewController {
appDelegate.launchOnboardingIfNeeded(with: containerController)
}
if let activity = connectionOptions.userActivities.first ?? session.stateRestorationActivity {
dPrint("\(#function) \(activity)")
masterViewController?.restore(from: activity, isStandalone: false, persistentId: scene.session.persistentIdentifier)
}
}
The print statement has an empty userInfo.
What's the problem?