Post

Replies

Boosts

Views

Activity

New async await CloudKit Methods - What do you think?
Anybody converting from CKQueryOperation to the new CloudKit async await methods? If so, what do you think? I'm currently playing with func records(matching query: CKQuery, inZoneWith zoneID: CKRecordZone.ID? = nil, desiredKeys: [CKRecord.FieldKey]? = nil, resultsLimit: Int = CKQueryOperation.maximumResults) async throws -> (matchResults: [(CKRecord.ID, Result<CKRecord, Error>)], queryCursor: CKQueryOperation.Cursor?) and func records(continuingMatchFrom queryCursor: CKQueryOperation.Cursor, desiredKeys: [CKRecord.FieldKey]? = nil, resultsLimit: Int = CKQueryOperation.maximumResults) async throws -> (matchResults: [(CKRecord.ID, Result<CKRecord, Error>)], queryCursor: CKQueryOperation.Cursor?) They seem to work fine and eliminate completion handlers.
0
0
1.6k
Nov ’21
Reality Kit - Move Function Not Working.
I want to move an Entity in from the right programmatically, but the move function is not working. I am using image tracking. I can place the entity statically, so I know I'm detecting the image. Here is my function. func placeMyPictureEntity(imageAnchor: ARImageAnchor) {         if let entity = try? Experience.loadMyScene() {             entity.scale = SIMD3(0, 0, 0)             let imageAnchorEntity = AnchorEntity(anchor: imageAnchor)             imageAnchorEntity.name = imageAnchor.name!             // Position the entity to the side             let anchorWidth = Float(imageAnchor.referenceImage.physicalSize.width)             entity.setPosition(SIMD3<Float>(x: 20.0*anchorWidth , y: 0.0, z: 0.0), relativeTo: imageAnchorEntity)             let newTransform = Transform(scale: SIMD3(20.0, 20.0, 20.0), rotation: simd_quaternion(0, 0, 0, 1), translation: SIMD3(x: anchorWidth, y: 0.0, z: 0.0))             entity.move(to: newTransform, relativeTo: imageAnchorEntity, duration: 2.0, timingFunction: .easeIn)             imageAnchorEntity.addChild(entity)             // Add anchor to scene             arView.scene.addAnchor(imageAnchorEntity)         }     } Any help would be most appreciated. Thanks.
0
0
627
Mar ’22
Frame Rotation versus Object Rotation
Anybody else come from an Aerospace background? In aerospace, the vector is stationary and the frame is rotated, for the most part, whereas here, the frame is stationary and the vector is rotated. Opposite rotations. It would be nice to have one document which discusses all of the reference frames with cartoons showing the axes. The Ferry Building example helped me a great deal when I looked at a map of the Ferry Building area and realized that the cardinal axis that location anchors are pretended is South (along the z axis). Makes sense. That's why it needed to be rotated by -51.4 degrees.
0
0
519
Mar ’22
Attributed Text Missing Tint Color on Image after Creating From CloudKit Bytes
I've created a simple project which uses CloudKit to store an attributed text as Bytes (Data) The attributed text includes an image with an orange tint color. In my simple project, I have two labels, one for the attributed text which I am loading into CloudKit (putLabel) and one for the attributed text created from the CloudKit data record (getLabel). The putLabel shows the orange image correctly, but the getLabel with attributed text downloaded from the iCloud data shows it as a black image. No tint color. Anybody have any ideas on how to get an attributed text with tint color from CloudKit? Here's the archive code \\ Convert into Data data = try? NSKeyedArchiver.archivedData(withRootObject: mainString, requiringSecureCoding: false) and here's the unarchiver code newStr = try? NSKeyedUnarchiver.unarchivedObject(ofClass: NSMutableAttributedString.self, from: data) The code snippets are missing some things, but they work.
0
0
888
Jul ’22
About AR Anchor's Orientation (Some Issues and Other Things)
I've been playing around with ARKit and I am interested in the orientation of ARGeoAnchor, ARImageAnchor and ARFaceAnchor. First of all, I notice that Apple says that ARGeoAnchor is based on an East-North-Up orientation, with its x- and z-axes matching the longitude and latitude directions. This should actually be characterized as an East-Up-South orientation (see https://developer.apple.com/documentation/arkit/arconfiguration/worldalignment/gravityandheading). I created an image to illustrate my point. It's the ferry building. Referring to the ARKit 4 presentation (wwdc20-10611), one can see that the 'Ferry Building' label is initially facing south and needs to be rotated by approximately -51.4 degrees about the y axis in order to face in the proper direction. As far as ARImageAnchor is concerned, it appears to me that the coordinate system is as in the below image. This is surprising to me as I would have expected it to be x to the right, y pointing up in the image and z pointing out of the image. It appears that ARPlaneAnchor's orientation is the same as ARImageAnchor. As far as ARFaceAnchor is concerned, its orientation is clearly explained in https://developer.apple.com/documentation/arkit/arfaceanchor and the orientation seems consistent to me. I wish that the other anchors were explained as well. Anyway, feel free to chime in with corrections and comments.
1
0
796
Oct ’22
Deleting then Replacing CKRecords of a Certain Type - Mixed Results
I am working on an update to one of my apps. The app uses CloudKit and utilizes the Public and Private databases. The user data is stored in the Private database. I have created methods to convert from CKRecords of the user's type to Codeable Structs and encode in json format and decode the json data into the array of Structs. I also have a method to create a CKRecord of the user's type from the Struct data. I am working on giving the user the option of replacing the CKRecords in the cloud with CKRecords created from a json file. I have a method which deletes all of the CKRecords followed by a method which uploads the CKRecords created from the json data. If I wait a while after this operation without using the app, it works well. But if I try to access the saved CKRecords shortly after the methods are executed, I have mixed results. Sometimes, I get less than what I uploaded and sometimes I get more than what I uploaded. I use try await on both methods and use the return value of the first method (delete) as an input into the second method (upload). Both the delete and upload methods use modifyRecords(saving: saveRecords, deleting: recordIDs, savePolicy: .allKeys, atomically: false) I do not use the modifyRecords method to do both at the same time. I use two modifyRecords methods. In all cases, the results show that the operations completed successfully even when there was an issue. I'd like for the delete method to delete all of the data and for the upload method to upload all of the json data without requiring an excessive delay.. Any advice would be most appreciated.
1
0
459
Apr ’23
SwiftUI MagnifyGesture Suggestion
I am testing out the new MagnifyGesture SwiftUI feature. My suggestion is to bring the view being magnified to the top of all views in the hierarchy while it is being magnified. I've submitted the suggestion in Feedback Assistant. Any comments on this suggestion?
0
0
399
Jul ’23
UICalendarView on Mac Catalyst - Command Key for Multiple Date Selection
A good while back, I created a Mac Catalyst version of an app. The app uses UICalendarView for both iOS and Mac. I have multiple date selection enabled. In the past, I thought I could select multiple dates on the Mac without needing to use the Command key modifier. And now I can't. Is this a change or am I dreaming? How can I go back to being able to select multiple dates without using the command key modifier?
0
0
511
Aug ’23
Xcode 15 RC - CKError: Account temporarily unavailable due to bad or missing auth token
I have two apps which uses the CloudKit public folder so that my users can access data. There's also a private database for them to save data. One is supposed to be able to access the public database without being logged into an iCloud account. And it was working fine. But now, with the simulator, I get the titled error message. It's fine on a device. But, if I log into the simulator with my iCloud account, I can access the public data.
0
0
625
Sep ’23
SwiftUI tabItem Label Text Cut Off on iPad
I have an app with a TabView. The tabItems look fine on the iPhone, but one is cut off on the iPad. See the picture below. The code is simple. Here it is. .tabItem { Label("Saved", systemImage: "lock.fill") } On the iPhone, the image is positioned below the text. On the iPad, the image is positioned before the text. 'Save' would work, but that's not correct either. I'm using Xcode 15 and my minimum deployment is iOS 17. Anybody have a work around for this?
4
0
1.1k
Sep ’23