Posts

Post not yet marked as solved
1 Replies
750 Views
I'm currently developing a multi-platform app where a standalone Watch app collects data, summarises it, then stores the summary in CoreData. The summary gets synchronised across all devices by CloudKit. However, the raw data (e.g. RR interval data from a Polar H10 heart rate monitor) are important from an historical perspective: forming the basis of further analysis, perhaps via AI. Given the limited storage, battery and processing resources on the Watch, it would be inappropriate to persistently store, or perform complex analysis of, the raw data on the Watch. My preferred solution would be to transfer the raw data to a Mac and, once successfully received, delete it from the Watch (also from CloudKit?). The Mac would then perform further analysis and propagate an additional summary to all other devices. The problem I foresee is that, if using CoreData/CloudKit synchronisation, deleting from the Watch would delete from all other devices. With my currently limited understanding of such synchronisation, I don't see a way of not then automatically deleting the Mac's CoreData records. Perhaps the solution is to have a separate CoreData container on the watch for the raw data, a separate CloudKit raw data container, and a separate Mac raw data container - then perform the deletes upon receipt of CloudKit update notifications (i.e. not via automatic syncs). The raw data are immutable, so there's no need to deal with updates. I'd appreciate advice/suggestions on a workable solution. Regards, Michaela
Posted Last updated
.
Post not yet marked as solved
1 Replies
852 Views
I'm currently rewriting an app developed over many years in Objective-C, Swift, SwiftUI, and an SQLIte database. Until now, I'd avoided CoreData because I'd been using SQL databases for decades (so was comfortable) and had concerns with CoreData's use of NS types. However, the new app will be multi-platform and share/sync data via CloudKit - which will be a pain in the derriere with SQLite (though not insurmountable). So, I'm going to do a test import of two related entities, 1,000 records and 4,500 records, to see how things go. There are more tables, but this will be just a test. My intended process is: Export the SQLite tables, "main" and "details", separately, to CSV. There are linking IDs. In the new app, load each CSV file into DataFrames using the TabularData framework. For each row in the "main" DataFrame, filter the "details" DataFrame rows on the "main"'s ID, then create Core Data's "main" entity along with the associated "detail" entities. Do a context.save() - after each "main" or in batches? Is there a better (less coding?) way? My understanding is that I can't just populate each set of entities separately and then expect an automatic creation of the relationships. I've seen reference on the Web of Core Data "linking attributes", rather like joins in SQL, but I see no mention of such in the Xcode DataModel builder, nor class definitions. Am I correct in this understanding? Regards, Michaela
Posted Last updated
.
Post not yet marked as solved
0 Replies
496 Views
I had a Big Sur MacMini update (non Beta) get stuck and nothing would fix it, so I then decided to go to Monterey (beta). After some initial problems, related to a Big Sur update waiting in the wings, the Monterey installation started - and then got stuck. The same problem: got so far then no further, time after time. I tried Safe Mode start-ups, but to no avail. During a shutdown, which also seemed to be blocked, I became aware of HDD noise from the networked backup drive. A backup was in progress! When I turned off automatic backups in TimeMachine (and disconnected the drive), the Monterey install worked - and I suspect the Big Sur update would have done also.
Posted Last updated
.
Post not yet marked as solved
1 Replies
892 Views
DataFrame(contentsOfJSONFile:url) (and it's MLDataTable equivalent) assumes that the rows to be imported are at the root level of the JSON structure. However, I'm downloading a fairly large dataset that has "header" information, such as date created and validity period, with the targeted array at a subsidiary level. The DataFrame initialiser has JSONReadingOptions, but these don't apply to this situation (i.e. there's nothing that helps). It seems that I'm faced with the options of 1) stripping the extraneous data from the JSON file, to leave just the array or 2) decoding the JSON file into a bespoke struct then converting its array into a DataFrame - which removes a lot of the benefits of using DataFrame in the first place. Any thoughts? Cheers, Michaela
Posted Last updated
.
Post marked as solved
2 Replies
886 Views
The TabularData DataFrame writeCSV method formats Double (and possibly Integer) numbers that are >= 1000 with a comma thousands separator and surrounds the output in double quotes. Numbers less than 1000 are not double-quoted. If the resulting CSV file is then read by DataFrame contentsOfCSVFile an error is thrown, i.e. a type mismatch. This happens irrespective of whether the types option is set in the CSV read, or not. There is no option in DataFrame writeCSV to specify no thousands separator, nor any other obvious way of preventing the double-quoting. Currently, I "fix" the problem by reading the CSV in Numbers, setting the faulty column(s) to Numeric then exporting back to CSV. Any thoughts on preventing the issue in the first place?
Posted Last updated
.
Post not yet marked as solved
2 Replies
6.9k Views
I'm devloping an iOS App for the Polar H7 and H10 Heart Rate sensors and it's crucial that the App monitors the attached device's battery level.For ayone who needs to get the battery level from a BLE device (if it supports such), the Battery Service UUID is 0x180F and the battery level characterisitc UUID is 0x2A19, reporting a one byte value with the battery level as a percentage (UInt8). Details are at https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.battery_service.xmlIn my Swift 3 code, having discovered the Service and the Characteristic (2A19), I do a peripheral.readValue(for: battChar) then a peripheral.setNotifyValue(true, for: battChar). The value is then provided in the didupdatevalue for characterisitc function. Not surprisingly, my Polar devices do not constantly update the battery status but must be interrogated from time to time using the peripheral.readvalue(for: ...) function.I hope this helps someone, somewhere, sometime. 🙂
Posted Last updated
.
Post not yet marked as solved
2 Replies
786 Views
When an iOS 14 beta device is connected to my MacBook running Big Sur 11 beta 10, files can be transferred to the iOS device via Finder, but not from iOS to the MacBook. No error is given and the transfer drag-and-drop appears to have worked as normal, except the file doesn't get transferred. It worked in the previous beta of Big Sur, although was problematic in earlier betas.
Posted Last updated
.
Post not yet marked as solved
11 Replies
3.7k Views
WCSession sendmessage from iPhone to Watch is working (Beta 1 to 3), but I've not been able to get a message from the Watch to the Phone. Watch to phone doesnt work in the sample app (Potloc) either, although under current betas (XCode, iOS and Watch) Potloc will not install on the watch and I haven't bothered to find out why.I can't get debug to work with the Watch app, despite workarounds suggested elsewhere, so it's hard to tell what's going on with WCSession.Has anyone got WCSession sending messages from watch to phone?Cheers.
Posted Last updated
.
Post not yet marked as solved
0 Replies
409 Views
An event created in Apple's Calendar app can have a user-supplied address ("Location"), which gets geocoded into the EKEvent record. These coordinates are then accessible via EventKIt in EKEvent.structuredLocation, but the original (or derived) address is not - even though a debug console print of a structuredLocation shows the address. Is here any way of Swift accessing the stored address? Obviously, an address can be created by reverse geocoding, but this consumes resources unnecessarily and might not return the "correct" address. Regards, Michaela
Posted Last updated
.
Post not yet marked as solved
3 Replies
4k Views
I often have need for multi-segment (hierarchical) pickers with dynamic data: in UIKit I achieve this by reloading a subsidiary component after the user picks a value from the higher level component, e.g. for Country then State.I've been trying to achieve the same sort of effect with a SwiftUI Form containing multiple (two to start with) Pickers, but without success. The ForEach(0 ..< elements.count) pattern doesn't work with second and subsequent levels in the hierarchy because the number of elements in these levels changes depending on the chosen top level, e.g. countries have different numbers of states. The compiler throws a warning that the ForEach(0 ..< ) pattern can only be used with constants and to use ForEach(array, id: ): the results are unpredictable anyway with the 0..< approach, with subscript out of range crashes.I can get correct display of second level choices based on the selected first level, but the Selection binding of the Picker doesn't work, i.e. no check marks and no display of selected element - only the available choices: Picker(selection: $selection, label: Text("SubGroup")) { ForEach(subGroups, id: \.id) { subGroup in Text(subGroup.element) } }With the ForEach(0 ..< pattern, the $selection refers to an Int, whereas using an Identifiable array the selection is (presumably) based on the id. But how to specify the binding for an id-based selection? Indeed, is this possible at all? I've seen a few posts on the Web querying this, with no answer.UPDATE: OK, fixed it 🙂 I'd been using UUID as the id for each group and each subgroup within a group. When I use a unique integer id (or double, e.g. 1.1, 1.2 etc for two-level hierarchy) in an identifiable model, everything is fine. However, my code needs to provide the id of the initial selected (first?) row of the lower-level Picker when the higher level has changed.Regards,Michaela
Posted Last updated
.
Post not yet marked as solved
0 Replies
377 Views
I'm working on a cross-platform app that displays time-dependent information via SwiftUI Views, updated automatically or by user interaction. For the tvOS version (which is now working as a full-screen app on tvOS13.4) I'd like the ability to show the app's data in PIP when the user navigates to a different app (such as a TV program) or, better still, as a rolling banner at the bottom of the screen. However, my understanding of the tvOS 14 beta implementation of Picture-in-Picture is that an app invoking PIP must play video content, not the non-media content of updating SwiftUI Views. Is this correct? Is there any way of keeping an app active, but minimised, when the user invokes another, unrelated, app?
Posted Last updated
.
Post not yet marked as solved
3 Replies
693 Views
The Destination of a NavigationLink is instantiated, but not displayed, when the View with the NavigationLink is instantiated. If the destination view then performs a significant amount of processing every time the origin view changes, but prior to the destination view needing display, there can be significant degradation of app performance. E.g. I've added SwiftUI Views to an existing app in order to analyse accumulated data; the user selects filter and statistics parameters from Pickers prior to pressing the "Calculate" button (NavigationLInk). The Link destination is instantiated and executed (eg data calculations)every time a property (e.g. filter selection) changes in the origin view before the user has pressed the Calculate button.Also, I assume that all subviews of a View are instantiated when the parent View is instantiated, even though they may not all be on screen. Add to this the fact that ObservedObjects, when changed, trigger a redisplay of any/all? containing Views.So, all of this leads me to suggest that design of SwiftUI apps is critical, especially where the app has many views and/or there is complex processing as a result of user interaction.I look forward to suggestions and/or pointers to best-practice design.Regards,Michaela
Posted Last updated
.
Post not yet marked as solved
0 Replies
327 Views
On retrieval within an iOS 13 beta app of a route for a workout created by the Apple Watch OS 6 Beta, HKWorkoutRoute provides incorrect course property (heading) for locations after the user has reversed direction (i.e. a 180 degree turn) and remains incorrect thereafter. A separate iOS app, recorded concurrently, shows the corect heading. The error is roughly 180 degrees, so it looks like the turnaround has not been recognised and/or the computation of the new heading not performed correctly. The turns were always counter-clockwise.
Posted Last updated
.
Post not yet marked as solved
2 Replies
743 Views
MacOS 10.15 (on a MacBook Pro) Finder connects to (mounts) iOS devices from at least iOS12.1 onwards, but there's no way to save, or otherwise process (e.g. Share), files listed under apps that allow iTunes file sharing. Drag and Drop, Command-C,etc have no effect. Also, there is no way of adding/replacing files.Has anyone else had this problem and/or found out how to Save?UPDATE: 10 June 2019, I've now filed a bug report.UPDATE: 21 June 2019, fixed in MacOS 10.15 Beta 2 (19A487l) and iOS 13.0 Beta 2 (17A5508m)Regards,Michaela
Posted Last updated
.
Post not yet marked as solved
3 Replies
1.5k Views
I have a complex iPhone app that I originally created as a Master-Detail (Split View) design, but later changed to "normal" (modal) segue from the Master (initial) view controller to the Detail. This was because another view controller in the hierarchy also needed to segue to the Detail view, which then caused memory issues beause of the way split-views are implemented. As far as I can tell, I changed all necessary code and everything worked fine, with no memory leaks or excessive memory use.However, with all iOS 12.2 betas on all devices (simulator and physical), using Xcode 10.2 betas, there are hundreds of memory leaks within the app, but mostly in the "Detail" view. I'm suspicious that there might be some residual code "behind the scenes" that's causing the problems. The same app under pre iOS 12.2 versions shows no memory leaks: none, zilch, zip.Has anyone rejigged a split-view controller and if so were there any memory leak issues?I have filed a bug report, but I'm still wondering if there's a residual issue with the way I made the change.UPDATE 14 June 2019: Apple has confirmed that this was a bug, which has been fixed as of iOS 12.4 beta 4 (16G5046d).Thanks, Michaela
Posted Last updated
.