Post

Replies

Boosts

Views

Activity

Reply to scrollTo() leads to invalid UI in VStack in iOS 16
Claude31, I'm afraid I can't agree with your opinion. Let me describe my requirements, which I believe it's very typical ones and make sense to most, if not all, people: When specifying .top option, the item to be scrolled to should show up on the top of the screen. However, if that pushes the items before it outside screen and, at the same time, there are no enough items after it to fill up the screen, SwiftUI should find a proper position to show it. The above requirements are exactly the behavior of scrollTo() in List. I don't understand why VStack/LazyVStack/LazyVGrid don't implement the same behavior. Why would anyone like to have their current (buggy) behavior? Can you think of any use cases? In my opinion that behavior doesn't make sense at all. If SwiftUI engineers really interpret the .top value that way (I really doubt it), then I think they should introduce another option value to support List like scrolling behavior. I can't use the code you suggest, because that's not my. purpose. I'd like to scroll to the last item. It's just that SwiftUI should handle the corner cases properly. Regarding the async call, it's required when navigating to a view.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23
Reply to scrollTo() leads to invalid UI in VStack in iOS 16
Thanks, but I don't want to set anchor to nil, because it has the same result as setting anchor to .bottom in this case, which in my opinion is bad UX (I want the item to show up on top of the screen when the LazyVStack has a lot of items). Background: my app currently uses List and setting anchor to .top works well. I was considering to change List to LazyVStack and ran into this issue. EDIT: or did you suggest it as workaround? Yes, it works, but unfortunately it's bad UX. I'm thinking to keep using List until the issue is fixed.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23
Reply to How does "xcrun simctl runtime add <path>" command work?
Hmm...I think my question is a basic user question and understanding it helps me (and perhaps other users) better use Apple's technologies. I understand it's Apple's culture to not disclose its product details, but it's bad that the culture is often used as an excuse. Anyway I have deleted the simulator image file I downloaded and Xcode works fine (it would be absurd if it didn't). I compared "df -m" output on my MBP before and after I deleted the file. There is little change (as expected).
Oct ’23
Reply to Does CloudKit guarantee CKRecord.Reference is always valid?
[quote='810806022, DTS Engineer, /thread/766748?answerId=810806022#810806022'] When saving a record that contains a CKReference field, CloudKit verifies that the target record exists in the same record zone. If it doesn't, CloudKit reports an error and does not proceed the save. [/quote] Hi Ziqiao, Thanks for your explanation. It has been very helpful. I'm going to create a FB to request adding information like this to CloudKit document. Your answer has covered the scenario in my original question. If you don't mind, I have a further quesiton. Can I assume that CloudKit makes sure that CKRecord.Reference is always valid in general? Let's consider a different scencairo, for example. Setup: suppose we have account a1 in the database, and there are no transactions associated with it yet. User first adds a transaction t1 on device A. The device saves the change to cloud. User then deletes account a1 on device B before the device receives the change in step 1 from cloud. Since there isn't t1 on local data store, the operation should succeed locally. Then device B tries to save the change on cloud. My question: what will happen when device B saves the change in step 2 to cloud? A) If t1's reference to a1 is created with CKReferenceActionDeleteSelf, I think CloudKit will delete t1 automatically. (A note to myself: will device B receives CKDatabaseNotification and sees t1 when doing CKFetchDatabaseChangesOperation?) B) If t1's reference to a1 is created with CKReferenceActionNone, CloudKit will do nothing and the data on cloud becomes inconsistent. Does this mean it's up to app developer to set up the reference with proper action and otherwise CloudKit doesn't guarantee reference validity? [quoted] In the case you described, where a1 is not a new record, I'd expect that CKModifyRecordsOperation returns you an error. Did you not get that? [/quoted] I'm evaluating if it's feasible to add CloudKit support (specifically, CKSyncEngine) to my app. I'm still in the early phase of trying to understand how it works. So I haven't tried any code yet (partially beause it involves timing and it's hard to get definite conclusion based on experiment results). Thanks Again.
Oct ’24
Reply to A question on account change handler code in CKSyncEngine demo project
[quote='811736022, Apple Staff, /thread/767491?answerId=811736022#811736022'] In the above case (.switchAccounts), as shouldDeleteLocalData is true, at the bottom of the function deleteLocalData() is called. That clears syncengine's current state (stateSerialization) and re-initializes, which will cause the engine to fetch the new account's data from CloudKit from scratch. [/quote] Thanks. May I ask how re-initialization could " cause the engine to fetch the new account's data from CloudKit from scratch"? In my understanding deleteLocalData() resets appData and calls initializeSyncEngine() to create a new CKSyncEngine instance. There is no code to load local data from the new account's document folder into appData. That part of code is in SyncedDatabase actor's init, which I don't think get re-called in this scenario. So I suspect, after switching new account, the app will show an empty list even if the new account has data on iCloud. Am I missing something? PS: I can't do the experiment at the moment because I don't have a proper environment to compile the project (I'm wating for the new mac mini 7 :)
Oct ’24
Reply to A question on account change handler code in CKSyncEngine demo project
[quote='811949022, Apple Staff, /thread/767491?answerId=811949022#811949022'] As long as automaticallySync is true, CKSyncEngine schedules an initial sync on init, and since we're starting fresh with this instance of CKSyncEngine, it will go and fetch everything from the server (i.e. all contacts saved under the new account) and handle them locally. [/quote] Thanks a lot for the detailed explanation! I would never be able to figure it out myself if you didn't mention it.
Nov ’24