Post

Replies

Boosts

Views

Activity

Reply to Warning: Reference to captured var 'hashBag' in concurrently-executing code
I have found the solution myself. It's actually straightforward, set project min platform to 10.15 and I can do this without warnings anymore: Task { bagLock.lock() hashBag["file"] = hash bagLock.unlock() } Actor is too heavy for this scenario because I have several variables like this in an async function; Mutex is quite new and my project has to target a much older platform like 10.15 which enables me to use Task async.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’25
Reply to self.window.isVisible = NO not working in windowDidLoad
More on applicationShouldHandleReopen. it appears that it is called only during debugging. For normal/direct run (double click in Finder) and observe messages in Console, I don't see any: - (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)hasVisibleWindows { NSLog(@"%s %d", __func__, hasVisibleWindows); return NO; }
Topic: UI Frameworks SubTopic: AppKit
Mar ’25
Reply to self.window.isVisible = NO not working in windowDidLoad
After many hours of digging, it turned out that another possible bug caused this weird problem. It seems AppDelegate applicationShouldHandleReopen is always called no matter if there is an existing running instance. This is true no matter if a project is created using XIB based style or new storyboard style; it's also not related to languages (OBJC or Swift). I verified this on newly created projects. My app has some custom actions to do in applicationShouldHandleReopen that eventually shows the main window. Since now it's called unconditionally, it will show main window on launch. I also verified on my old MBP, applicationShouldHandleReopen is NOT called on app launching during debugging. Is this applicationShouldHandleReopen behavior by design on new macOS versions (13+)?
Topic: UI Frameworks SubTopic: AppKit
Mar ’25
Reply to self.window.isVisible = NO not working in windowDidLoad
Mystical event happens when I debug the following code: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [NSOperationQueue.mainQueue addOperationWithBlock:^{ [self.mainWC setup]; }]; } I add a watch self.window.visible and set 2 breakpoints: one at the addOperationWithBlock line and the other inside the block. When the first breakpoint is hit, self.window.visible is NO. But as soon as the second breakpoint is hit, self.window.visible becomes YES. In IB "Visible at Launch" is unchecked for the main window. I have tried clean and rebuild but to no avail. But I cannot reproduce this in a newly created project with similar XIB setup. Does anyone else have such a bizarre situation like mine?
Topic: UI Frameworks SubTopic: AppKit
Mar ’25
Reply to self.window.isVisible = NO not working in windowDidLoad
I forgot to mention that my tests are done on the old XIB project because my app was created long ago before storyboard was invented. I tested again on my old MBP with Xcode 14.2 and macOS 12.7.6 (Monterey). Either combination works: Leave "Visible at Launch" checked (default) in IB and self.window.isVisible = NO in awakeFromNib Uncheck "Visible at Launch" in IB and self.window.isVisible = YES in awakeFromNib I believe there are some minor changes at the lower OS level that break this "old" behavior.
Topic: UI Frameworks SubTopic: AppKit
Mar ’25