Post

Replies

Boosts

Views

Activity

Reply to NSPersistentCloudKitContainer "migrate to a completely new store"?
So I believe I am overthinking it!lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: "Model") let storeLocation = URL(fileURLWithPath: "/path/to/cloud.store") let storeDescription = NSPersistentStoreDescription(url: storeLocation) //Set the container options cloudStoreDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "com.myCompany.myApp2") // TODO: Migrate Core Data Store to new Model Version container.loadPersitentStores... ... }()This should be enough to handle the migration from Container 1 to 2, since the data is already stored in Core Data. Then instead of hooking up a persistent container to the old CloudKit container (which would probably throw errors due to mismatched Schema), we can use CloudKit to fetch and confirm all data has already transfered properly, fix missing data, and delete the recrods in Container 1.I decided not to Migrate Containers for this, instead Im using "versioned entity" approach, but I just wanted to post this here in case it can help someone else. If someone uses this approach, I'd love to hear your feedback whether it worked or not.
Mar ’20
Reply to SwiftUI Drag image OK on macOS but KO on iPadOS
You are not the only one. I haven't tested on my iPad yet (still 13.3) but I am experiencing the same empty rectange on my iPhone 11 (13.4.1). Others have experienced a similar bug on the mac, https://swiftui-lab.com/drag-drop-with-swiftui/ .The preview image is rendered properly in the iOS simulator though for me. You can submit a bug report in the Feedback App.
Apr ’20
Reply to Access to lasso tool selection
There is no callback like canvasViewDidSelectStrokes, but we can now inspect the strokes of a PKDrawing. I haven't done this yet, but you could: Make a SelectionPanGestureRecognizer: UIPanGestureRecognizer that tracks touches along with the PKCanvasView.drawingGestureRecognizer (use UIGestureRecognizerDelegate to allow simultaneous touches, and obviously you only need to track if the selected tool is the lasso). When the touch is over, create a bounding box of your gesture touches. Inspect your PKDrawing.strokes array and check for intersection with your bounding box from above. SelectionPan should track minX, minY, maxX, maxY. You will use these values to determine your boundingBox: CGRect and then for each PKStroke in PKDrawing.strokes check for an intersection with the PKStroke using boundingBox.intersects($0.renderBounds) to determine if the PKStroke is selected. Edit: After thinking about it, this will also select PKStrokes that aren't selected by the lasso tool(it's more complex than just a bounding box). It would probably be better to use your own BoundingBox Selection tool and CALayer that draws the selection box, in which case the above would work.
Jun ’20
Reply to Access to lasso tool selection
I was wrong in parts of my first reply. You can't use the simple RectSelection to match up with PKLassoTool. You'll need your own overlay, and probably your own ToolPicker at that point. The upside is the selection logic is much simpler and it might be good enough depending on your application. If you want a complex lasso, like the one in PencilKit, you're gonna need to do a bunch more work! Basically you will need to determine if an "irregular polygon ( the lasso path) contain a point". You will need to implement some algorithms in swift. I would start with this link reading about the problem. Stack Overflow - https://stackoverflow.com/questions/217578/how-can-i-determine-whether-a-2d-point-is-within-a-polygon/ Im pretty sure the solution you posted wouldn't register a path if the selection path encircled it without intersecting it.
Jun ’20
Reply to Side-by-side sections in UICollectionViewCompositionalLayout?
I was able to achieve side by side column sections by setting the scroll direction.                let config = UICollectionViewCompositionalLayoutConfiguration()         config.scrollDirection = .horizontal         layout.configuration = config         return layout The downside being that the orthogonal scrolling was a pretty choppy since my columns were long lists. I don't think this will work for your layout though, since your layout has sections "flowing" in both axes. I believe you will need to use a single section with multiple groups. This will make "syncing" to the datasource more complicated since we can't use the section index, but it should be possible.
Jul ’20
Reply to Define Array of protocol which conforms to Identifiable
If the id type is the same, you can use "Type Erasure", but as the name implies, you will be dealing with a reduced type, which is probably not what you want. class AnyIdentifiable<T>: Identifiable {     var id: T { _id }     private let _id: T     init<U: Identifiable>(_ identifiable: U) where U.ID == T {         _id = identifiable.id     } } struct TypeA: Identifiable {     var id = UUID() } struct TypeB: Identifiable {     var id = UUID() &#9;&#9;var name = "b" } let a = TypeA() let b = TypeB() let anyA  = AnyIdentifiable(a) /** - Note: `anyB` does not have a `name` property as it is of type AnyIdentifiable*/ let anyB = AnyIdentifiable(b) let anyIDs: [AnyIdentifiable<UUID>] = [anyA, anyB] You can apply similar logic above creating an AnyPlayable which will also need to forward your play() but again, you will be dealing with a reduced type. So only the properties in AnyPlayable will be available, ie. id and play().
Sep ’20
Reply to Calendar List is empty after authorization
I don't know if it's a bug or not but store.reset() does not seem to actually reset the store like the comments suggests, It essentially is as if you released the store and then created a new one. It brings it back to its initial state. If we actually do create a new store, the issue seems to be resolved. So the access handler should look something like this: store.requestAccess(to: .event) { (granted, error) in if granted { self.store = EKEventStore() ... } I found the answer on this post. Stack Overflow - https://stackoverflow.com/questions/58873603/ekeventstore-calendars-is-always-empty-after-clean-install.
Jan ’21
Reply to A serious bug in PencilKit that make all apps with PencilKit useless in iOS16
I am the developer of Pencil it in, also an indie and pretty worried about this. I haven't downloaded Xcode 14 yet so I can't test, but I have a feeling the issue is in the backing CAMetalLayer, since it only happens when writing, possibly related to drawableSize. If you have Xcode 14, it might be worth building and logging the drawableSize or other CAMetalLayer properties (bounds, frame, ...) between iOS 15/16. Getting a reference to the metal layer can be a bit tricky; it's within a private view. The hierarchy is PKCanvasView -> PKTiledView -> PKMetalView. You can access it with something like: for v in canvasView.getAllSubviews() { for l in v.layer.sublayers ?? [] {     if let metalLayer = l as? CAMetalLayer {         print("Layer is ", metalLayer)          }      } } Where the helper function getAllSubviews() can be found on Stack Overflow I will keep this forum updated on any progress made and would appreciate anyone else experiencing this do the same.
Jul ’22