Post

Replies

Boosts

Views

Activity

Remote control for iPad from BLE device
I need to implement a remote control for a SwiftUI app running on iPad. I would need to handle 2 different events like Start / Stop. On software side, I plan to use .onReceive to listen to BLE device. So my questions: I need realtime reaction (a few 1/100 s max) can any BLE remote control do the job ? If anyone has tested some low cost remote, I am interested to know. Or should I look for Homekit solutions ? Or use an iPhone as remote controller ?
0
0
876
Dec ’22
On daylight saving time change
Last night we change hour for daylight saving time (at 2:00 it would be 3:00). So I made a simple test to set an alarm at 2:10 At 1:59, clock jumped logically to 3:00 no alarm At 3:10, alarm rang (in fact I had turned it off and back on, but that has no influence) I set an alarm at 3:15, of course it rang I set a new alarm at 2:20 It rang at 3:20 Conclusion: Clock app "replicates" the alarms between 2:00 and 2:59 into 3:00 - 3:59. Which is great, not to miss any. Question: Is this specific to Clock app or a more general system behaviour for all time events ? If so, there may be a side effect: I set an event A to turn On a light at 2:45 And set event B to turn it Off at 3:15 Then B will occur before A and the light will remain On There is no perfect solution ("warping" 2:00 - 2:59 into a minute at 3:00 would creates other issues). Extra question: What happens on winter time ? Will alarm ring twice at 2:10 ?
0
0
2.2k
Mar ’23
Execution order of multiple onChange
I have declared an array as a State var @State var proba : [Int] = [10, 40, 40, 10] The array is updated in onAppear : .onAppear { proba = arrayOfTuples.map { (proba, _) in proba } print("proba", proba) } The array is used for TextFields: ForEach(0..<proba.count, id: \.self) { index in TextField("N", value: $proba[index], format: .number) .frame(width: 40) .onChange(of: proba_kWh[index], perform: {[oldValue = proba_kWh[index]] newValue in print("proba onChange", index, oldValue, proba[index], newValue) }) When View appears, I get some onChange (as initial values did change) proba [10, 20, 60, 10] // onAppear changes 2 values: 1 and 2 proba onChange 2 40 60 60 // index 2 is changed before 1 proba onChange 1 40 20 20 I know that order of execution is not guaranteed, but in this specific case, I did thought it would be in the order of the array reading…
0
0
735
May ’23
Default Text width in SwiftUI different for MacOS and iPadOS ?
I have an app that runs eitheir as MacOS or iPadOS. After a few changes to adapt to API differences (PasteBoard notably), app runs OK on both. But the layout of views is messy when running on iPad. Reason seems to be that Text are not using the same default font size, or that the same system font size does not use the same space. Same issue when using segmented picker for instance. Configuration: Xcode 14.2 MacOS 12.6.6 Simulator: iPad Pro (12.9") - iOS 16.2 Is it a correct analysis ? Is there a simple workaround, to avoid the need to redesign all views for iPadOS ?
0
0
788
Jun ’23
Did anything change in LazyVGrid in Xcode 15 ?
If I run the exact same code on MacOS 12.7 (Xcode 14.2) and MacOS 15.0.1 (Xcode 15.0.1). In a scrollView, I display lines (lineDivider) and then a LazyVgrid, applying some offset: ScrollView(.vertical) { ForEach(1...50, id: \.self) { index in LabelledDivider(label: "\(index)", color: .gray.opacity(0.1)) .offset(y: CGFloat(65*index - 50) } LazyVGrid(columns: gridItemLayout, spacing: 33 ) { ForEach ($allItems.theItems) { $item in ItemView(item: item) } } .offset(y: 40) } In Xcode 14.2, I get the first layout and in Xcode 15.0 the second on right: The divider line is at the same position, but the view in grid is not. If I change .offset(y: 40) to .offset(y: 60) I get the same layout. So my questions: did anyone observe similar change ? is it due to Xcode, to MacOS ? Is it documented somewhere ?
0
0
659
Oct ’23
CameraUI SpatialVideo library error
This app allows to take photos. It works OK, but since recently I get the following error message: ERROR: PHOTO not found in table CameraUI-SpatialVideo of bundle CFBundle 0x283e96220 </System/Library/PrivateFrameworks/CameraUI.framework> (not loaded) What is this spatial video ? I'm just using still images, not using CameraUI.framework.
0
0
721
Jan ’24
Using and expressing "case let" statements
After seveal years with Swift, I still find it hard to use the if case let or while case let, even worse with opotional pattern if case let x?.So, I would like to find an expression to "speak" case let more naturally.Presently, to be sure of what I do, I have to menatlly replace the if case by the full switch statement, with a single case and default ; pretty tedious.I thought of canMatch or canMatchUnwrap … with:So, following would readif case let x = y { // if canMatch x with yif case let x? = someOptional { // if canMatchUnwrap x with someOptionalwhile case let next? = node.next { // while canMatchUnwrap next with node.nextAm I the only one with such problem ? Have you found a better way ?
5
0
7.7k
Jun ’21
Height of safe area margin in iPhone 12 Pro Max
I have an image to fill the entire screen, even behind the notch. So I set the Top margin to safe area to -44. That works OH on all iPhones… except on iPhone 12 ProMax simulator. Here I get a few pixels uncovered at top. I had to change value to -48 to get everything OK. So question is: has "notch area" which defines safe area increased 4 pixels on iPhone 12 Pro max ? If so, is it a hardware change ?
1
0
4k
Jun ’21
Cannot activate Xcode Edit>Substitution menu
When editing a Swift file in Xcode 12.2, I wanted to change the quotes autocompletion. For this I looked at the Edit > Substitution menu and selected smartQuotes. From this point, the whole substitution menu is disabled, no way to enable back. Opened another file: same issue. Opened another older version of Xcode: the same. Opened Xcode 12.2 on another Mac: same thing How can I re-enable the menu ? Whilst typing this message, I tried again and the menu is once again reactivated ! I did nothing (at least intentionally). Was it some type of time out or time required to complete a task ? But did not return to normal on the other Mac. But now, 10 more minutes later, it is disabled once again… That's the type of surprise effect I do dislike in an app…
1
0
701
Dec ’20
Uppercased words are not spoken correctly
Using AVSpeechSynthesizer, I noticed that some works in UPPERCASe are not correctly spoken. SMALL is pronounced small but WIDTH is pronounced W-I-D-T-H I reproduced the problem in playground: let sentence = "Hello everyone. Two minutes to go. SMALL WIDTH." let synthesizer = AVSpeechSynthesizer() let utterance = AVSpeechUtterance(string: sentence) utterance.voice = AVSpeechSynthesisVoice( &amp;#9;language: "en-GB" ) utterance.rate = AVSpeechUtteranceDefaultSpeechRate * 1.05 synthesizer.speak(utterance) Is it the expected behaviour ?
1
0
1.2k
Mar ’21
Distribution of MacApp outside of Appstore for a demo version
I consider the following distribution scheme for some Mac App: distribute the commercial (paying) version on Appstore propose a free demo version (of course limited in some aspects) on a web site. This would of course be notarised. The reason is to avoid having several versions on the Appstore which could create some confusion. The 2 versions would have similar names and differ essentially in the size of data they can handle. Does anyone know if this is authorised by the Appstore Guidelines ? Or must I publish both on the AppStore ? Is there a risk my app being rejected as spam ?
1
0
591
Apr ’21
Sandbox - security scoped URL - MacOS
In a MacOS App: When I create a file (in a folder), I save a security bookmark for the file. if I ask user to authorise its folder (before creating the file in it), I can save its bookmark too, allowing to create other files in this folder. So, when I create a file and need to create a companion (eg, a Results file), I first ask access to the folder, then create the file and create the results file in the same folder (hence having sandbox authorisation). My understanding is that it is not possible to programmatically create and save the folder bookmark, after deriving its url from the file url, without requesting user to explicitly grant access (with NSOpen panel) ? Which would be very logical as it would deny the goal of security bookmarks. So, is user explicit authorisation required (logical but creates more complexity when user moves files in the Finder). Note: In fact don't really need it, as I save bookmark for every accessed file, but I would like to know.
1
0
802
Apr ’21
Getting back from Splitview
In this app, I have: a VC as entry point (root) which segues (push) to a SplitViewController On iPad, when I get into the splitView, I can get back to the root by dragging down the split view. But on iPhone, this does not work: even though presentation is .automatic, Splitview covers all screen. No way to get back. I tried to create a back button in the detail views… Could not get it. What is the best way to do this ? is there a setup for the initial segue or the views presentation modes to allow pop back ? can I add a back button ? Where, calling what action to return ? I cannot embed splitViewController in nav stack … I would like to have the same solution on both iPhone and iPad…
1
0
624
Jun ’21