Posts

Post not yet marked as solved
0 Replies
365 Views
I've got a simple Core Data Entity that is synchronized with CloudKit via NSPersistentCloudKitContainer. I can read my local fields, but how can I read fields like "Created" & "Modified" from CloudKit? Do I have to add them to my Core Data model and populate them myself? P.S. In his fantastic WWDC talk "Using Core Data with CloudKit", at around 21:40, Nick Gillet talks about how Core Data entities in the CloudKit store are prefixed with "CD_" to separate the things that it manages from the ones CloudKit implements. Then he says: "You wouldn't believe how many people add modify date to their CKRecord". Like it's something redundant.
Posted
by Stann.
Last updated
.
Post marked as solved
1 Replies
364 Views
Imagine I have a game with new levels every day. Users play my game and their progress is saved in Core Data, which is then synchronized with CloudKit via NSPersistentCloudKitContainer. Users' progress is about 500Kb for each level/day. That's 5 Mb in 10 days. Or 182 Mb in a year. If the user plays my game for a year, gets a new iPhone, and installs my app again — will the NSPersistentCloudKitContainer eventually download all 182 Mb of users' data!?
Posted
by Stann.
Last updated
.
Post not yet marked as solved
0 Replies
428 Views
The StateObject doesn't deinit, if I use it's @Published var in an .alert() in iOS15. Here is the minimal code to reproduce the problem: @main struct MyApp: App { var body: some Scene { WindowGroup { MainUIView() } } } struct MainUIView: View { var body: some View { NavigationView { NavigationLink("Go to Child View", destination: ChildView()) } .navigationViewStyle(.stack) } } struct ChildView: View { @StateObject var vm = ChildViewModel() var body: some View { Text("Hello, World!") //HERE. I have to use $vm.showingAlert from the StateObject: .alert("Alert Title", isPresented: $vm.showingAlert, actions: { Button("OK") { } }, message: { Text("Alert Message") }) } } @MainActor final class ChildViewModel: ObservableObject { @Published var showingAlert = false init() { print("INIT") } deinit { print("DE-INIT") } } If you go to ChildView and back - you won't see "DE-INIT" printed in the console on iOS15. Is it a bug or is my code wrong? PS Yes I need the showingAlert var to be in the ChildViewModel as it has business logic which shows an Alert in the View.
Posted
by Stann.
Last updated
.
Post not yet marked as solved
0 Replies
625 Views
I have PKCanvasView in my iPad app. When the user rotates the iPad - I need to scale the Canvas and all the strokes accordingly. So far I've found two ways to scale a PKCanvasView, first with a .zoomScale: GeometryReader { geo in // Canvas View goes here... } .onChange(of: geo.size) { newSize in let canvasScale = newSize.width / myDefaultCanvasWidth canvasView.minimumZoomScale = canvasScale canvasView.maximumZoomScale = canvasScale canvasView.zoomScale = canvasScale } Second with CGAffineTransform: //For short: let transform = CGAffineTransform(scaleX: scaleWidth, y: scaleHeight) canvasView.drawing = canvasView.drawing.transformed(using: transform) Please help me understand the difference between those two methods and which one is correct and preferable? Thank you.
Posted
by Stann.
Last updated
.
Post not yet marked as solved
1 Replies
810 Views
The default PKInkingTool with inkType .pen seems to be limited in its stroke width. With a maximum width of around 25.66. Why is that? How can I increase it? Example code: canvasView.tool = PKInkingTool(.pen, color: .black, width: 10) print(canvasView.tool) //Prints: PKInkingTool(tool: <PKInkingTool: 0x2837ba140 com.apple.ink.pen color=UIExtendedSRGBColorSpace 0 0 0 1 width=10.000000>) canvasView.tool = PKInkingTool(.pen, color: .black, width: 20) //Prints: PKInkingTool(tool: <PKInkingTool: 0x282730140 com.apple.ink.pen color=UIExtendedSRGBColorSpace 0 0 0 1 width=20.000000>) //Problem starts here: canvasView.tool = PKInkingTool(.pen, color: .black, width: 30) //Prints: PKInkingTool(tool: <PKInkingTool: 0x28077a0c0 com.apple.ink.pen color=UIExtendedSRGBColorSpace 0 0 0 1 width=25.659260>) canvasView.tool = PKInkingTool(.pen, color: .black, width: 100) //Prints: PKInkingTool(tool: <PKInkingTool: 0x2824e08e0 com.apple.ink.pen color=UIExtendedSRGBColorSpace 0 0 0 1 width=25.659260>) How can I increase the stroke width? 🤔
Posted
by Stann.
Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
The regular .sheet is too big for my use case, it almost covers the whole screen on iPad. I need to display a .sheet with UIModalPresentationStyle.formSheet. How can I do that with SwiftUI?
Posted
by Stann.
Last updated
.
Post not yet marked as solved
0 Replies
671 Views
I want to work directly with PKStrokes in my app. To transform and change them individually. By one or by grouping them. I thought a perfect way of keeping track of them is to put them in a Set<PKStroke>. By doing this I receive an error: "Type 'PKStroke' does not conform to protocol 'Hashable'". Correct me if I'm wrong, but aren't all PKStrokes unique? Thus they should be eligible to be kept in a Set? What is a correct way of accessing/grouping/storing PKStrokes then? Manually searching for them in canvasView.drawing.strokes? Thank you very much!
Posted
by Stann.
Last updated
.