Post

Replies

Boosts

Views

Activity

Xcode iOS15 beta 2 .tag in ForEach doesn't compile
in Xcode iOs15 beta 2 the .tag modifier in a ForEach statement gives the following compile error "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions" the error shows up on the .navigationBarTitle line but its due to the .tag line works fine on all previous releases. anyone know how to fix? code example below func content() -> some View {         let rentFrequencies = RentFrequency.allCases         return List {             ForEach(rentFrequencies, id: \.self) { rentFrequency in                 if rentFrequency != RentFrequency.NoFrequency {                     HStack() { Text(rentFrequency.name).tag(rentFrequency.id) // Including this tag makes it not compile                         if rentFrequency == type {                             Spacer()                             Image(systemName: "checkmark") .foregroundColor(.accentColor)                         }                     }                     .onTapGestureForced(perform: { self.type = rentFrequency })                     .frame(width: nil, height: 32.0)                 }             }         } .listStyle(InsetGroupedListStyle())         .navigationBarTitle("Rent Frequency")     }
0
0
1.1k
Jun ’21
Capture of 'notification' with non-sendable type 'NSNotification' in a `@Sendable` closure
Get this warning compiling with ios16 b5. anyone know what this is? no warning on ios15. Capture of 'notification' with non-sendable type 'NSNotification' in a @Sendable closure The line it shows on is: let myObject = notification.object as! MyObject I also noticed that NSNotificationCenter notifications in general seem to have broken in iOS16 betas. Are they getting removed?
0
1
1.4k
Aug ’22
new swift concurrency model with core data willSave()
anyone know how to use the new swift concurrency model (ie. await context.perform and context.perform) core data willSave()? for example. how would I ensure this is thread safe? changing self.managedObjectContext!.performAndWait to await self.managedObjectContext!.perform means I have to change willSave() to async which then means it never gets called because its not overriding the correct method anymore. override public func willSave() { self.managedObjectContext!.performAndWait { if self.modifiedDate == nil || Date().timeIntervalSince(self.modifiedDate!) >= 1 { self.modifiedDate = Date() } } super.willSave() }
0
0
814
Oct ’23
AppIntents: pauses in siri's speech and hiding dialog text
Is it possible to put a pause in Siri's responses to an AppIntent? in the code below id like Siri to pause a bit longer than she does between sentence one and sentence two. i've tried using "..." and multiple "." similar to what she does when she's responding to "how is the market" if you ask a HomePod - she pauses a bit longer between her comments on each market, a bit more than an end of sentence - more like the pause between each point when you are going through a list of bullet points - which is really what i'm using this for. Also is it possible to hide all or part of of the dialog text displayed? so she says it but doesn't show it. I've got a view which shows a better formatted representation of what she says than the text itself. struct TestAppIntent: AppIntent {     static var title: LocalizedStringResource = "A question?"     static var openAppWhenRun: Bool = false     @MainActor     func perform() async throws -> some IntentResult {         return .result(             dialog: "sentence one. sentence two", view: someView()         )     } }
1
2
1.4k
Jul ’22
A navigationDestination for <App.Entity> was declared earlier on the stack. Only the destination declared closest to the root view of the stack will be used.
anyone been able to get rid of this error? A navigationDestination for <App.Entity> was declared earlier on the stack. Only the destination declared closest to the root view of the stack will be used. Seems to happen when im using a NavigationLink(value:) and a NavigationLink(destination:) in the same class. I'd think it would make sense to be able to use both methods? ios16 b5
1
0
3.5k
Aug ’22
Calling actor method from another actor
so ive got an actor that im using to control concurrent access to some shared data. I have a second actor that controls concurrent access to another set of different shared data actor DataManager { static let shared = DataManager() func fetchData() async { modifySomeData() let blah = await SecondDataManager.shared.fetchDifferentData() } } actor SecondDataManager { static let shared = SecondDataManager() func fetchDifferentData() -&gt; [SomeData] { return stuff } } im finding that because of the await in the fetchData() method, the actor no longer ensures that the DataManager.fetchData() function can only be executed one at a time thus corrupting my shared data because fetchData() needs to be async due to the call on the second actor method. Any way to ensure DataManager.fetchData() can only be executed one at a time? normally id use a DispatchQueue or locks. but it seems these can't be combined with actors.
1
0
3.0k
Sep ’22
Usage of CKQueryOperation.recordMatchedBlock and .queryResultBlock
Anyone know the correct usage for CKQueryOperation.recordMatchedBlock and .queryResultBlock? Xcode is telling me to use them as the old .recordFetchedBlock and .queryCompletionBlock are deprecated, but there isn't any documentation to say how they should be used. ChatGPT, Bard etc aren't able to provide a correct answer either: specifically, I need to convert the following to use those methods: operation.recordFetchedBlock = { record in // Convert CKRecord to Core Data object and save to Core Data self.saveToCoreData(record: record) } operation.queryCompletionBlock = { (cursor, error) in // Handle potential errors if let error = error { print("Error syncing first of month records: \(error)") } if let cursor = cursor { // There are more records to fetch for this category, continue fetching self.continueSyncing(cursor: cursor, completion: completion) } else { // Done syncing this category, move to the next sync task completion() } }
1
0
981
Aug ’23
Loading large number of records into the CloudKit public database
Anyone know how to load a large number of records into the CloudKit public database? I need to load 1.2million records (about 150Mb) into the public database. no binary data. basically just a bunch of exchange rates that I need to have available to all my users. I've been trying for months. have tried: loading into core data on a device or simulator individually or in batches ranging from 400 records to 2500 (more than that exceeds batch size limits). it will start to sync and then stop. can often get it to restart by restarting device or similator but will eventually corrupt the database in iCloud requiring a reset of the environment. generally can get the load to go for a few days and load maybe 500k records before it breaks. to do that have to put delays up to a minute between batches loaded into core data. have tried doing it using the CloudKit.js framework and loading from a server. this works for a small number of records. but limits are really small doing it through that interface. after a while it locks you out. don't get anywhere near the number of records I need to load. I'm stuck. has anyone found a way? same issue on all versions of iOS - 14, 15, 16b1
2
1
1.6k
Jun ’22
How to safely access Core data NSManagedObject attributes from a SwiftUI view using swift concurrency model?
How do I safely access Core data NSManagedObject attributes from SwiftUI view using the swift concurrency model. My understanding is we need to enclose any access to NSManageObject attributes in await context.perform {}. But if I use it anywhere in a view be that in the body(), or init() or .task() modifier I get the following warnings or errors: for .task{} modifier or if within any Task {}: Passing argument of non-sendable type 'NSManagedObjectContext.ScheduledTaskType' outside of main actor-isolated context may introduce data races this happens even if I create a new context solely for this access. if within body() or init(): 'await' in a function that does not support concurrency but we cant set body or init() to async an example of the code is something along the lines of: var attributeString: String = "" let context = PersistentStore.shared.persistentContainer.newBackgroundContext() await context.perform { attributeString = nsmanagedObject.attribute! }
2
1
1.7k
Dec ’23
NavigationStack with NavigationLink - back button only works correctly one deep
So I have a navigationStack which has a NavigationLink that navigates to the next view. That view then has its own NavigationLink that navigate to a 3rd view. if the user clicks on the back button on the 3rd view (View3) to return to the previous view (View 2), it goes right back to the starting view (View 1). an one else have this issue or know how to fix? ios16b1 example below: View 1: NavigationStack {                 View2()                     .navigationTitle("View 2")             } View 2: List {        VStack (alignment: .leading) {                     NavigationLink("View 3", destination: {                         View3()                     }) } }
3
2
1.4k
Jul ’22
Core Data CloudKit stops syncing after incomprehensible archive error
Ive been getting this error on an app in the dev environment since iOS16. it continues to happen in the latest iOS release (iOS18). After this error/warning, CoreData_CloudKit stops syncing and the only way to fix it is to delete the app from all devices, reset the CloudKit dev environment, reload the schema and reload all data. im afriad that if I ever go live and get this error in production there won't be a way to fix it given I cant go and reset the production CloudKit environment. It doesn't happen straight away after launching my app in a predictable manner, it can take several weeks to happen. Ive posted about this before here and haven't got a response. I also have a feedback assistant issue submitted in 2022 as part of ios16 beta that is still open: FB10392936 for a similar issue that caused the same error. would like to submit a code level support query but it doest seem to have anything to do with my code - but rather the Apple core data CloudKit syncing mechanism. anyone have any similar issues or a way forward? > error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _requestAbortedNotInitialized:](2200): <NSCloudKitMirroringDelegate: 0x301e884b0> - Never successfully initialized and cannot execute request '<NSCloudKitMirroringImportRequest: 0x3006f5a90> D823EEE6-EFAE-4AF7-AFED-4C9BA708703B' due to error: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x73, 0x61, 0x6d)" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x73, 0x61, 0x6d)}
3
0
1.1k
Nov ’24
is there a demo app for the "Add configuration and intelligence to your widgets" WWDC session
is there a demo app for the "Add configuration and intelligence to your widgets" WWDC2020 session? Xcode doesn't autogenerate any of the code that the demo says it will and parts of the code show in the video is cut off on the screen so I can't see what the code is. keen to get the app so I can manually copy it in. also the written instructions at https://developer.apple.com/documentation/widgetkit/making-a-configurable-widget seem to miss parts out as Xcode doesn't generate the code that the instructions say it will. a demo app for that will also be helpful
5
0
1.7k
Jan ’21
Charts: customising chartYAxis values
anyone figured out how to customise the Y axis values? id like to be able to process the. axis values and. then display them in the. format id like. eg. "1000" I'd like to display as "1k" the furthest Ive been able to get is to get the axis to display a static text as the number ie "Y" in the code below. but I haven't been able to access the value. in the code below 'value' seems to be an AxisValue which stores the value but I can't seem to access it in a format I can process. .chartYAxis {                 AxisMarks() { value in                     AxisGridLine()                     AxisTick()                     AxisValueLabel {                     Text("Y")                     }                 }             } id like to be able to do something like this: .chartYAxis {                 AxisMarks() { value in                     AxisGridLine()                     AxisTick()                     AxisValueLabel {                         if value > 1000000000000.0 {                             Text("\(value / 1000000000000.0)t")                         } else if value > 1000000000.0 {                             Text("\(value / 1000000000.0)b")                         } else if value > 1000000.0 {                             Text("\(value / 1000000.0)m")                         } else if value > 1000.0 {                             Text("\(value / 1000.0)k")                         }                     }                 }             }
5
2
5.9k
Jun ’22