Post

Replies

Boosts

Views

Activity

Comment on Using NSSortDescriptor(key: "date", ascending: true
Hi Drew, my suggested solution does NOT work. I've used computed properties several times in my apps, but not for sorting, and I just assumed (incorrectly) that the solution would work - but it doesn't: Coredata does not allow sorting by computed property. There's no compiler error, just a crash. Normally I check my answers on the forum before posting, but on this occasion I made a faulty assumption. So, I apologise for wasting your time. Nor can you just change the attribute type to Date from String - this would require a Migration. Best wishes and regards, Michaela
Mar ’22
Comment on Using NSSortDescriptor(key: "date", ascending: true
Hi Drew, my suggested solution does NOT work. I've used computed properties several times in my apps, but not for sorting, and I just assumed (incorrectly) that the solution would work - but it doesn't: Coredata does not allow sorting by computed property. There's no compiler error, just a crash. Normally I check my answers on the forum before posting, but on this occasion I made a faulty assumption. So, I apologise for wasting your time. Nor can you just change the attribute type to Date from String - this would require a Migration. Best wishes and regards, Michaela
Mar ’22
Comment on Help with first watch app
There's been a lot of pressure from developers for SwiftUI Map to have the same capabilities as MapKit, so I expect (hope?) that future releases will make life easier. That said, I'm having problems with a MacOS mapping app, SwiftUI and MapKit coordinator, related to a bug somewhere in Apple code. One of my tasks in the next day or two is to collect all the evidence and submit a bug report.
Mar ’22
Comment on Help with first watch app
Nice solution to making the annotations!! The Map facility within SwiftUI is very limited, basically restricted to showing annotations at known coordinates, e.g. giving it coords you already have somewhere in your data (or per your idea). There's no way of plotting a track either ( a poly line). To put an annotation on the map with a tap or long-press requires 1) a gesturerecognizer in your SwiftUI View (easy) and 2) a method to convert the press's view x,y location to map coordinates. Unfortunately the latter is only available in the MapKit framework (i.e.not SwiftUI), which then requires a coordinator from SwiftUI to MapKit and some fairly (unfairly??) complex code to manage everything. I've done MapKit coordinators, but there's a lot of code and might be too much to put in a post.
Mar ’22
Comment on TabularData Framework: DataFrame as a List in SwiftUI
I was in a hurry to get this sample done before visitors arrived, so it's not as robust as it could be. It would be better to initiate the dataTable in DataModel as @Published var dataTable = DataFrame(). With this initialisation, the reference to model.dataTable! in ContentView doesn't need to be (shouldn't be) force unwrapped i.e. just use model.dataFrame. Also, with a large input csv file it would be better to load as a background task (via DispatchQueue) and rely on the @Published var dataTable to populate the SwiftUI List.
Mar ’22
Comment on Help with first watch app
Well done! It's good to see another retireee doing app development. I'd already assumed you are very tech savvy, although, yes, Swift and particularly SwiftUI can be hard to get one's head around (was for me, anyway) after years of procedural programming. Sharing of the phone and watch ViewModal code is the best way to go (though potentially more complex), especially if both devices will have the same functionality. Normally I use a separate Framework (library) for all of my Data Model (ViewModel) code, with OS specific code as needs be. This is because most of my apps now are Multiplatform (Mac, iPad, iPhone, Watch and sometimes TV), with data sharing via the Cloud: my watch apps are now standalone, i.e. not tethered to the phone. However, your need appears to be for reliable realtime communication, which probably wouldn't suit a Cloud approach
Mar ’22
Comment on Help with first watch app
In your Watch's session didReceiveUserInfo function you need to update the ViewModel variable (i.e. data that get displayed) using DispatchQueue.main.async { update the var } as you probably did in the phone app if using my sample code. This is because communication sessions are run on a background queue, whereas views (and their associated data) can only be updated on the main queue. Good luck and regards, Michaela
Mar ’22
Comment on Help with first watch app
Mmm, I haven't had that message before, but I'm aware that it's been a problem for others from time to time. I suggest checking if your session (instance of WCSesssion) returns .ispaired == true on the phone immediately after your session gets activated. If it returns false, then see if the iPhone and Watch really are paired. It might also be an idea to check all other aspects of the paired device information as per the documentation https://developer.apple.com/documentation/watchconnectivity/wcsession. What versions of Xcode, iOS and watchOS are you using? If needs be, I can try to replicate the problem here. Regards, Michaela
Mar ’22
Comment on help me! (data sync between watch and phone)
Are you using SwiftUI or UIKit? If SwiftUI, the sample code I provided earlier works: make sure you follow what I said for the phone app. The key aspects are: 1) the Phone Data Model must be an ObservableObject, 2) you must use @Published on the variable (count) that you want synced in your view, 3) you must update the @Published count in the data model from incoming watch data by using DispatchQueue.main.async 4) the SwiftUI view must declare the data as @ObservedObject var ........ Oh, and I'm a lady - so just call me Michaela - not Uncle.
Oct ’21