Post

Replies

Boosts

Views

Activity

HealthKit data - Is HKStatisticsCollectionQuery slow?
Hi, I am using HealthKit for the first time. I am using HKStatisticsCollectionQuery. I am running my code iOS 17 on a physical iPhone. It takes several seconds to query data, for example 1 day worth of heart rate at 1 minute resolution. I changed the resolution to 1 hour, expecting it to be faster, but it's pretty much the same… I have been following the official documentation and sample code. I also compiled in Release, but that didn't really help for HKStatisticsCollectionQuery. I quickly looked with Instruments, the app is spending a lot of time in decoding data with NSXPCDecoder. Is there a way to speed data retrieval? Or this is "expected" latency?
2
0
411
Oct ’24
In iOS SwiftUI Document-based apps, how to show window of already opened document when trying to open the document a second time?
In a Document-based app, in SwiftUI (iOS 17), how to bring to front the window that shows an already open document, when trying to open the same document from the file browser, instead of opening a new window? This is to prevent opening the document twice and being able to edit it in 2 different editors. The official demo [1] does not handle this case. [1] https://developer.apple.com/documentation/swiftui/building_a_document-based_app_with_swiftui
1
0
394
Jan ’24
MKMapView scale in metric system or imperial system? (meter, kilometer; or foot, mile)
How can one set MKMapView scale unit to use the metric system (meter, kilometer) or the imperial system (foot, mile) in an app, in code? I looked in the SwiftUI documentation, I could not find any mention of this in the MKMapView doc. My phone is set to use metric system (metres) and Apple Maps does show the scale meters; but not my app. Thanks
0
0
768
Jun ’21
What is _VectorMath protocol? Conforming to VectorArithmetic and AdditiveArithmetic
Context While extending the Array type to conform to VectorArithmetic (for core animation experiment): extension Array: VectorArithmetic where Element: VectorArithmetic & AdditiveArithmetic { ... } I get the following error: Referencing operator function '*' on '_VectorMath' requires that 'Element' conform to '_VectorMath' and when calling the scale(by:) method: Referencing instance method 'scale(by:)' on 'Array' requires that 'Double' conform to '_VectorMath' Workaround Making type Element and Double conform to _VectorMath fixed the issue: extension Array: VectorArithmetic where Element: _VectorMath & VectorArithmetic & AdditiveArithmetic { ... } extension Double: _VectorMath { } Questions I tried looking for information on _VectorMath (note the underscore prefix) but I could not find anything in the official docs and not much on the internet. What is _VectorMath protocol? Where is it defined? Is it ok to use it like this? Or should I use a different approach?
4
0
1.4k
Dec ’20