@eskimo Do we have to file a bug for playgrounds? I am still on macOS BigSur, so can't run it on a command line project as it would require macOS 12 (Beta). I was preparing some tutorials to demonstrate async let so thought playgrounds was ideal as opposed to an iOS project
Post
Replies
Boosts
Views
Activity
Your code works fine on the following configuration:
macOS 12.4 (21F79)
Xcode Version 13.4 (13F17a)
Checkbox selection is restored on re-run
Give it like a few seconds for it to be persisted or tap on a different app for it to save the state.
Aim
To find the size (height) of a view
Approach
Use the GeometryReader on the .background of the view you want to calculate the size, that way GeometryReader wouldn't tamper the view's dimensions
Send the size (height) determined to the parent view using @Binding or Preferences
Binding
A reference to a value type
Preferences
You could read a bit about Preferences, it is used to send value to the parent views (opposite of what environment value does)
Create a PreferenceKey
Set the preference using .preference modifier
Detect the value change using onPreferenceChange
Works for me
I have a simplified example tried on macOS Ventura which seems to working ok.
Please check
Check your TableRow code, try to replace with TableRow with Text and see if it works
My Code
struct Message: Identifiable {
var text: String
var id: String {
text
}
}
struct ContentView: View {
let messages = [Message(text: "aaa"),
Message(text: "bbb"),
Message(text: "ccc")]
var body: some View {
VStack {
List {
Section {
ForEach(messages) { message in
Text(message.text)
.swipeActions {
Button(role: .destructive) {
// data.delete(datum)
} label: {
Label("Delete", systemImage: "trash")
}
}
}
}
}
}
}
}
Can you please watch https://developer.apple.com/wwdc22/10054, it goes into great detail step by step about the new navigation APIs
It might help to watch /read about the basics of SwiftUI, you have model that you can observe, so when the state of the model changes, your views would update, so your view should use the states to determine how the UI should look like.
@eskimo
I am using Logger (OSLog) and I don't want debug messages from frameworks like mentioned below.
What should I do to achieve that?
When I use CoreData / CloudKit especially NSPersistentCloudKitContainer I do see a lot of debug messages such as the ones below:
CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: <NSCloudKitMirroringDelegateOptions: 0x600002804090> containerIdentifier:<my bundle id> databaseScope:Private ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO useDeviceToDeviceEncryption:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x600001800260> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x600001800320> metricsClient:<PFCloudKitMetricsClient: 0x600001800390> metadataPurger:<PFCloudKitMetadataPurger: 0x6000018003a0> scheduler:<null> notificationListener:<null> containerOptions:<null> defaultOperationConfiguration:<null> progressProvider:<NSPersistentCloudKitContainer: 0x600000f0d000> test_useLegacySavePolicy:YES archivingUtilities:<PFCloudKitArchivingUtilities: 0x6000018003b0> bypassSchedulerActivityForInitialImport:NO
storeOptions: {
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x60000140ac70>";
NSPersistentHistoryTrackingKey = 1;
NSPersistentStoreMirroringOptionsKey = {
NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x60000230c380>";
};
NSPersistentStoreRemoteChangeNotificationOptionKey = 1;
}