Posts

Post not yet marked as solved
0 Replies
209 Views
I was able to add a spotlight effect to my entities using ImageBasedLightComponent and the sample code. However, I noticed that whenever you set ImageBasedLightComponent the environmental lighting is completely turned off. Is it possible to merge them somehow? So imagine you have a toy in a the real world, and you shine a flashlight on it. The environment light should still have an effect right?
Posted Last updated
.
Post not yet marked as solved
1 Replies
364 Views
Let's say I've created a scene with 3 models inside side by side. Now upon user interaction, I'd like to change these models to another model (that is also in the same reality composer pro project). Is that possible? How can one do that? One way I can think of is to just load all the individual models in RealityView and then just toggle the opacity to show/hide the models. But this doesn't seem like the right way for performance/memory reasons. How do you swap in and out usdz models?
Posted Last updated
.
Post not yet marked as solved
0 Replies
457 Views
I have the following code working great in iOS16 TextField( "Describe...", text: Binding( get: { promptText }, set: { (newValue, _) in if let _ = newValue.lastIndex(of: "\n") { isFocused = false } else { promptText = newValue } } ), axis: .vertical ) but in iOS 17 it breaks. But it breaks in a very mysterious way. Firstly, the @ FocusState doesn't work. Setting it to false does not dismiss keyboard. Fine, but also what's weird is that when I press the done button, the new line gets added to the textField anyway, even if I don't set the newValue. What's going on?
Posted Last updated
.
Post not yet marked as solved
0 Replies
517 Views
In https://developer.apple.com/wwdc22/10054 it is shown that the best way to organize an iPad layout is by: struct TwoColumnContentView: View { @Binding var showExperiencePicker: Bool @EnvironmentObject private var navigationModel: NavigationModel var categories = Category.allCases var dataModel = DataModel.shared var body: some View { NavigationSplitView( columnVisibility: $navigationModel.columnVisibility ) { List( categories, selection: $navigationModel.selectedCategory ) { category in NavigationLink(category.localizedName, value: category) } .navigationTitle("Categories") .toolbar { ExperienceButton(isActive: $showExperiencePicker) } } detail: { NavigationStack(path: $navigationModel.recipePath) { RecipeGrid(category: navigationModel.selectedCategory) } } } } NavigationModel defined as final class NavigationModel: ObservableObject, Codable { @Published var selectedCategory: Category? @Published var recipePath: [Recipe] @Published var columnVisibility: NavigationSplitViewVisibility } But what happens when in a child view, it triggers off some action in some other ViewModel that needs to update the navigation stack? struct ChildViewModel { func childViewCalledAndDidSomething { //now I need to update recipePath, how? } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
609 Views
public var zonesChangeToken: [CKRecordZone.ID: CKServerChangeToken]? { get { if(backingPreviousZonesChangeToken == nil) { guard let defaults: UserDefaults = UserDefaults(suiteName: CloudKitHandler.APP_GROUP_ID) else { return nil } guard let data = defaults.data(forKey: CloudKitHandler.CK_PREVIOUS_ZONES_CHANGE_TOKEN) else { return [CKRecordZone.ID: CKServerChangeToken]() } do { let unarchiver: NSKeyedUnarchiver = try NSKeyedUnarchiver(forReadingFrom: data) unarchiver.requiresSecureCoding = true backingPreviousZonesChangeToken = try unarchiver.decodeTopLevelObject() as? [CKRecordZone.ID: CKServerChangeToken] } catch { } } return backingPreviousZonesChangeToken } set(value) { backingPreviousZonesChangeToken = value guard let value = value else { return } guard let defaults: UserDefaults = UserDefaults(suiteName: CloudKitHandler.APP_GROUP_ID) else { return } let archiver: NSKeyedArchiver = NSKeyedArchiver(requiringSecureCoding: true) archiver.encode(value) archiver.finishEncoding() defaults.setValue(archiver.encodedData, forKey: CloudKitHandler.CK_PREVIOUS_ZONES_CHANGE_TOKEN) } }I'm trying to encode/decode a dictionary of IDs and Tokens. But for some reason the decode always gives me a nil.How to fix?Error Domain=NSCocoaErrorDomain Code=4864 "value for key '$0' was of unexpected class 'NSDictionary'. Allowed classes are '(null)'." UserInfo={NSDebugDescription=value for key '$0' was of unexpected class 'NSDictionary'. Allowed classes are '(null)'.}
Posted Last updated
.
Post not yet marked as solved
0 Replies
462 Views
Let's say the sequence of events go like thisI have token A for a Shared DatabaseRecords get created in Shared DatabaseI fetch for changes and downloaded new records, gets token BI accepted a new share in the same zone and databaseI take the new record (NEW_REC) from inside CKShare.Metadata and saves it, but I dont have a new tokenBut now NEW_REC gets deleted by the sharerI then fetch for new changes for the zone and use token B, but CK will not let me know NEW_REC is deletedI tested this using the dashboard, so it has nothing to do with my code.Is this intentional? I'm thinking that the algorithm is designed to work like this because it thinks that from the perspective of token B, NEW_REC never existed? So why bother telling the client is deleted?But that doesn't taken into account that the new record came from metadata. I also wonder the same case if you did CKQuery to get new records, without using CKFetchRecordZoneChangesOperation do you suffer from the same problem?
Posted Last updated
.
Post not yet marked as solved
1 Replies
419 Views
I'm trying to call CKFetchRecordZoneChangesOperation to get the latest changes from the shared database.But when I run that operation from inside didFinishLaunchingWithOptions, NSPersistentCloudKitContainer will break. It will save to coredata, but it will no longer sync to Cloudkit. It's as if it's paused. When I restart the app, the sync resumes.But if I call CKFetchRecordZoneChangesOperation later in the app lifecycle, say in viewDidLoad, everything works fine. Why is this?
Posted Last updated
.
Post not yet marked as solved
1 Replies
581 Views
I need to create some records in CloudKit for each user when they start an app.I can't just write a seed function that create records. Because when the user starts the app in two devices, they will each write their own seed record.What I want instead is for the first device to write to CloudKit gets to create the record. And then second device will simply update the values of those records no recreate them.How can I achieve this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
465 Views
The example they give in the doc is friends.@count https://developer.apple.com/documentation/coredata/nsderivedattributedescriptionBut is it possible to count the number of friends based on a condition? Like if friend.gender=male.@count?
Posted Last updated
.
Post not yet marked as solved
0 Replies
417 Views
I'm completely stuck on this one 😟I'm just presenting a simple UICloudSharingController and set the delegate.Even though my itemThumbnailData and itemTitle delegate methods are called (I can see from debugger) but they take no effect.The controller still shows the screen with "Untitled" and place holder image. Why?Further more, cloudSharingControllerDidSaveShare is also not called back when I click save.
Posted Last updated
.