Post

Replies

Boosts

Views

Activity

Reply to Loop over two arrays with different length
The loop will finish when arrayOfItems is finished. But it is a dynamic array in the sense that sometimes n could be 100 or 1000. What is the problem with the proposed solution ? It will work in all cases. n can be 100 or 1000, it will work the same. Using this approach I will have to create if statements every tens. So, it's not generic for any n numbers Effectively, as you don't know if n is 10 or 10 000 it is unpractical solution. You are just hard coding a computed solution. Don't do this.
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’21
Reply to Passing data from NSWindowController to its content NSViewController.
I can give up on Storyboards and switch back to Nibs On iOS, I use storyboard extensively. It is extremely convenient, as you see the app logic and you usually go from one view through the other by some type of segue. But on MacOS, I stay with Nibs. I don't find storyboard well suited with the multi window environment usual for Mac apps where you go from one window to another from many different actions (menus, contextual menus, …). In addition, it is clear that storyboard are not as well designed for Mac apps (just an example: 5 years later, no zoom yet). So, I would advise to go back to Nibs.
Topic: UI Frameworks SubTopic: AppKit Tags:
Feb ’21
Reply to Get the window titlebar background color
I think that titlebar has in fact the color of the window background, plus a non transparent effect that dims the bg color. Making the titlebar transparent will give it the exact color of background. You could try this (I tested, got a uniform red color): window?.titlebarAppearsTransparent = true // gives it "flat" look window?.backgroundColor = .red // set the background color https://stackoverflow.com/questions/47759424/how-to-colour-the-titlebar-of-nswindow Or look at this: https://stackoverflow.com/questions/47759424/how-to-colour-the-titlebar-of-nswindow
Topic: UI Frameworks SubTopic: AppKit Tags:
Mar ’21
Reply to Xcode User Interface Builder "Add Missing Constraints" adds random constraints
Is the "Add Missing Constraints" function in the Xcode User Interface Builder known to work properly, or should this functionality be avoided? I personally avoid it. Or more precisely I fire it to see what is proposed but then immediately undo as it often add extraneous constraints (they are not random, but the logic may be hard to understand). I declare as many constraints as possible in IB, much easier than programmatically. I may also create an IBOutlet for some constraints when I need to adapt (usually changing constant) in certain circumstances (such as for very small size screen). "height is ambiguous" or "vertical position is ambiguous", That is often because the reference element (to which the constraint is defined), is missing a vertical position. Is there a specific technique that should be used to handle constraints when building a UI? This is not a specific technic, just the way I proceed. I try to select "reference" elements that I position in the top view. Then other elements will be constrained relative to it. It may also be useful to create subviews that will hold some related objects. Then constraints are defined for the subview and objects inside are constrained with respect to their subview. A last thing, when there are many constraints, I give them an ID (#01, #02) to ease debug. Could you detail a case where you cannot make it work ?
Mar ’21
Reply to Schedule start of notification requests
You could call from func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) - Void) { if notification.request.identifier == requestIdentifier { completionHandler( [.alert,.sound,.badge]) // schedule next notification here } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to TableView relsoaddata from textField on the same viewController with TableView
It would be necessary to see the complete class code. Because you probably reload() before data are updated (due to some async call). But impossible to spot exactly where without getting the complete code. Please show also the loadData() func itself, as it was asked some time ago. As you call in viewDidAppear, may be table is displayed before the loading is complete. Do you call reloadData() for the tableView at the end of loadData() ? From there once the app is in memory, it works normally. Do you mean you may call the reload before the end of app loading ???
Topic: App & System Services SubTopic: Core OS Tags:
Mar ’21
Reply to Get the window titlebar background color
titlebarAppearsTransparent exists since MacOS 10.10. So I do not see a reason why this would not work on later OS. but the titlebar has still a lighter color than the background color. By chance I discovered that if I set When I test in an app (Swift), even without setting bg color for the window, everything is the same color. When you add: self.window.backgroundColor = [NSColor controlBackgroundColor]; Does it change the content color ?
Topic: UI Frameworks SubTopic: AppKit Tags:
Mar ’21