Post

Replies

Boosts

Views

Activity

Dark mode switching modifies ObservedObject
This is a SwiftUI Mac App. There is an observable object with a published array class AllObjects : ObservableObject { @Published var theItems = [Item]() } In the View, observed with: @ObservedObject var allObjects : AllObjects Item class is : class Item: ObservableObject, Identifiable { let id = UUID() var placeNo = 1 // Other properties } When I switch dark / light mode within the app (with a toggle) @Environment(\.colorScheme) var colorScheme the ObservedObject allObjects is modified: array is emptied: allObjects.theItems is now an empty array. What could cause the change to theItems ? I have checked that the only func un which theItems is reset to [] is not called.
2
0
685
Apr ’23
Several tags are inaccessible on the forum
I notice that several (most) tags are not accessible now (Nov 2, 19:30 GMT). For instance https://developer.apple.com/forums/tags/ios https://developer.apple.com/forums/tags/uikit https://developer.apple.com/forums/tags/macos https://developer.apple.com/forums/tags/appkit https://developer.apple.com/forums/tags/xcode https://developer.apple.com/forums/tags/interface-builder all with the same error: The page you’re looking for can’t be found But others are: https://developer.apple.com/forums/ https://developer.apple.com/forums/tags/swift Is it only me ?
4
0
1k
Nov ’23
Swiping Watch faces always display 10:09 before exact time
I know it is not a developer question, but getting the answer may help understand what we can get or not get on Apple Watch after Watch10. Since WatchOS10.2 when swiping face, time is always displayed first as 10:09:31 before setting the correct time one second later. Just in the same way as a long press. But the interest of swipe is to have immediately a different face displaying the correct time. Why is it so ? Is it due to (probably) now using SwiftUI ? Or is it a quick fix, reusing most of code for Lon,g press case ? It did not behave so with WatchOS 9 or before. Is there a setting to change ? It is really inconvenient (and ugly). I filed a bug report: FB13466486
1
0
1.3k
Jan ’24
AppstoreConnect does not show units and sales of last days
Today, on Dec 14, when I look for units or sales, all that occurred after December 3rd is ignored. Tens were downloaded since dec 3rd, and I could see them when connecting earlier today. When I want to set the time period, I see that any date beyond Dec 3rd is greyed (see attached screenshot). It used to work a few hours ago. This occurred immediately after updating MacOS to 14.2, but I tested on a Mac running 12.6 with the same result. Is it only me or does anyone see the same issue ? I filed a bug report: FB13468285
10
0
1.9k
Mar ’24
Why does the superview of a UITableViewController turns nil after unwindSegue ?
Here is the set up. I have a UITableViewController (controller 1), to which I get from a controller (0) As I need to add a searchView atop the tableView, I addSubview to the superview. This is done in viewWillAppear self.view.superview?.addSubview(searchView) // AboveTableView searchView.isHidden = true print("willAppear", self.view.superview, self.tableView.superview) It works perfectly well, I get: willAppear Optional(<UIViewControllerWrapperView: 0x103d2eef0; frame = (0 0; 393 852); autoresize = W+H; layer = <CALayer: From this VC, I segue to another VC (2) with a show segue and comes back with an unwindSegue to return to (1). Problem is that no, superviews are nil. @IBAction func unwindToTableViewController(_ sender: UIStoryboardSegue) { print("unwind", self.view.superview, self.tableView.superview) } gives unwind nil nil If I step back from this controller (1) to the controller (0) from which I segued and segue again to the TableViewController (1), everything works as expected. In addition, if I go from 1 -> 2 by instantiating (2), everything works OK when I unwind to (1). I know a solution is to refactor code replacing UITableViewController with a UIViewController and embed a TableView inside. But I would like to understand why my present design does not work.
3
0
1.1k
Dec ’23
View appears transparent over tableView, whatever alpha channel
I have a view in storyboard, with a tableView and a coloured UIView. The UIView is declared after tableView, so it appears on top of tableView. However, it appears semi transparent over the tableView. In addition, I cannot set its alpha channel to values other than 1 or 0 (e.g., 0.9) But if I create the view programmatically, the view if fully opaque as expected. What am I missing ?
1
0
1k
Jun ’24
Forcing screen orientation for a VC
This is an often asked question, but I just have a partial answer so far. There are some views (not all) that I need to present in Portrait only when running on iPhone. If I come from a TabBar, I just add the following code in the TabBar controller override open var supportedInterfaceOrientations : UIInterfaceOrientationMask { if UIDevice.current.userInterfaceIdiom == .phone { return [.portrait, .portraitUpsideDown] } } But I need to do the same when I get to the destination VC by a segue fired from a plain UIViewController or a Cell in a TableView. If I put the code in the destination controller, it has no effect. If I put in the originating VC, it works when segue is triggered from code (case 2 below). But I cannot make it work when segue is triggered in storyboard from the accessory action in the cell of the TableView. Where should I declare the supportedInterfaceOrientations ? Should I do it in the navigation root ? If so, how ? I tried in an extension UINavigationController, to no avail. or should I trigger the segue from accessory, not directly in storyboard but through an IBAction in code ? If that may help, an overview of storyboard setup: Also tried solution described here to no avail either: https://www.appsdeveloperblog.com/disable-rotation-of-uiviewcontroller-embedded-into-uinavigationcontroller/
1
0
863
Jan ’24
Using Color() in background modifier in SwiftUI does not work with Xcode 15.3
I had this code working properly in Xcode 17.0.1, with macOS target as 12.4 struct SyntheseView: View { @AppStorage("isDarkMode") var isDarkMode = false // more declarations ……… var body: some View { VStack { ZStack { // code ………………… } .frame(width: 500, height: 300) .background(isDarkMode ? Color(red: 0, green: 0, blue: 120/255) : Color(red: 1, green: 1, blue: 186/255)) } // VStack In Xcode 15.3, I get the error The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions If I comment out the background modifier, no issue. I converted all parameters in Color to Double without success If I replace by a fixed color as .background(.blue) No error. Even the simple .background(Color(red: 0.0, green: 0.0, blue: 0.5)) causes the error. But: .background(isDarkMode ? .blue : .red) does work. I tried to define the Colors as static color extensions to no avail. Another bizarre point is that a similar pattern works OK for another View. Did something change in Xcode 17.3 ?
1
0
1k
Mar ’24
A new message 'Answered by forumsContributor in' with a link to nowhere
I see this message for the first time: It is inserted in the OP (https://developer.apple.com/forums/thread/757852) but the link leads to nowhere (just the general page of the forum). In … what ?!? So I wonder what is the meaning of the message, its intent and use ? Or is it just a forum bug ? PS: surprisingly, this post appears in Forums general page (https://developer.apple.com/forums/latest), but not in forums feedback (https://developer.apple.com/forums/tags/forums-feedback) PS2: it appears, but after all the pinned messages which are older. Really confusing… I posted a bug report on this: Jun 23, 2024 at 9:29 PM – FB14024970
5
0
1.3k
Jul ’24
Irrelevant automatically generated answers on the forum
I've recently seen answers to posts that are apparently automatically generated but signed as App Store Connect Engineer. In several cases the answer is misinterpreting the OP. Here is an example: https://developer.apple.com/forums/thread/758391 The OP was really a developer question. Not related to a consumer feature. Is it really an automatic answer (which would be a bad trend for the forums IMHO)?
1
0
1.1k
Jul ’24
PullDown menu shows in reverse order when in landscape
I create a UIKit PullDown menu (in a positionMenu button), with the following code: func setupPullDownMenu() { let menu1 = UIAction(title: "Menu1") { [self] _ in // some code } let menu2 = UIAction(title: "Menu2") { [self] _ in // some code } let menu3 = UIAction(title: "Menu3") { [self] _ in // some code } let menu = UIMenu(title: "Positions", children: [menu1, menu2, menu3]) positionMenu.menu = menu positionMenu.showsMenuAsPrimaryAction = true }   In Portrait, options are listed as Menu1, Menu2, Menu3 But in Landscape it is the reverse: Menu3, Menu2, Menu1 I use Xcode 16.1ß and iOS 17.0 simulator Is it the expected behaviour ?
1
0
900
Aug ’24
preferredColorScheme not working with Xcode 16
In this app, I set the preferredColorScheme in main @main struct TheApp: App { @AppStorage("isDarkMode") private var isDarkMode = false var body: some Scene { WindowGroup { ContentView() .preferredColorScheme(isDarkMode ? .dark : .light) } } } isDarkMode is changed dynamically in code. When code is compiled with Xcode 15.3, the background of ContentView changes from light to dark or vice versa. When compiled with Xcode 16, no more change. However, direct changes to objects do work, such as: TextField("N", value: $t, format: .number) .frame(width: 40) .background(isDarkMode ? .gray : .white) What has changed in Xcode 16 ? Is it documented somewhere ? I saw this SO thread which describe similar problem. https://www.reddit.com/r/swift/comments/upkprg/preferredcolorscheme_toggle_not_working/
10
0
1.4k
Oct ’24
Changing background colour of Button changes the container background
To change the background of a TextField, I simply apply: TextField("0.0", value: $p, format: .number) .textFieldStyle(PlainTextFieldStyle()) .background(.red) That does only work with plain style, but it works. Trying something similar on a button changes the container view background. The only solution I've found is to overlap with a Rectangle. How is it ? A SwiftUI bug ? A current limit of Swift ? A rationale for it ? There a better solution I've not found ?
3
0
531
Oct ’24
Developing a driver to read HFS disks on MacOS Sonoma and newer
Capability to read and write ofd HFS disks on Mac has been removed since a long time. Capability to simply read was also removed since Catalina I think. That is surprising and sometimes frustrating. I still use a 90's MacBook for a few tasks and need from time to time to transfer files to newer Mac or read some old files stored on 3.5" disks. Solution I use is to read the disk on an old Mac with MacOS 10.6 (I'm lucky enough to have kept one) and transfer to USB stick or airdrop… As there is no USB port on the Macbook of course (and I have no more a working 56k modem to transfer by mail), only option if not 3,5" disk is using PCMCIA port on the MacBook for writing to an SD Card to be read in Mac Sonoma. But reading directly 3.5" disk would be great. Hence my questions for the forum: how hard would it be to write such a driver for READING only HFS on Mac Sonoma? There are some software like FuseHFS. Did anyone experience it ? Did anyone have a look at the source code (said to be open source). does anyone know why Apple removed such capability (I thought it was a tiny piece of code compared to the GB of present MacOS)? Thanks for any insights on the matter.
4
0
694
Mar ’25