Post

Replies

Boosts

Views

Activity

Reply to Presentation single with code
Could you explain better what you get and what you want ? I try to formulate You click button, calling obrirAmbCodi, which opens a window finestra3 when you click again on that button, a new, similar window opens (probably stacked over previous one ?) in such a case, you would want just to display the already opened window, not create a new one. Is that correct ? If so, you could: In the class where obrirAmbCodi is, declare a var var controller: NSWindowController? test if nil ; if so instantiate     @IBAction func obrirAmbCodi(_ sender: NSButton) { if controller == nil {         let storyboard:NSStoryboard = NSStoryboard(name: "Main", bundle: nil) controller = storyboard.instantiateController(withIdentifier: "finestra3") as? NSWindowController // could be nil             controller?.showWindow(self) }     } dismiss the controller when you close window and set to nil Note: you could test if the window is open instead of testing controller
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Adding Restores Everything
The thing is I need noRepFav because I don't want duplicates in my array. There are very simple ways to achieve this with a single array. Before appending to this array, check if the item already exist. I'm confused with this code: you have at least 2 different TableViewControllers (FavouritesVC, HockeyDetailVC). Both of them have handleFavNotification. It is not clear where you delete, where you add, where it is added back.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Override info.plist value at runtime
You cannot do that. info.plist is part of bundle and cannot be changed at runtime. See details here for instance: https://stackoverflow.com/questions/40214673/setting-value-to-info-plist-file-from-swift?noredirect=1&lq=1 But why change the info.plist and not directly the appearance ? https://developer.apple.com/documentation/appkit/nsappearancecustomization/choosing_a_specific_appearance_for_your_macos_app
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’21
Reply to Xcode Swift Coremotion Pedometer update every step
AFAIK, answer is no. A few reference material: https://stackoverflow.com/questions/36439912/live-updates-with-cmpedometer-coremotion h t t p s : / / medium.com/simform-engineering/count-steps-with-cmpedometer-on-iwatch-94b61bc3b87e The pedometer is a higher level object on Core motion. It sets its own refresh rates and we can get updates through a closure, so it’s on its own schedule, not one we can control. Just an idea, for what it's worth. Using the actual speed and the recent ratio steps/speed, maybe you could estimate the count at the frequency you want, and display it. Then, as soon as you receive a new pedometer information, update everything. I don't know if that would be good enough or too chaotic information display.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Navigation Controller Back Button not working correctly when tapped
No, never met this problem. Could you tell: Which version of Xcode ? On simulator or device ? Which OS version in anycase. Have you changed the button programmatically, in anyway ? Are you sure you have nothing overplayed over "Back" ? Could debug view hierarchy when running to check for this ? Eventually, create the smallest possible project to reproduce and attach the full project folder here.
Topic: UI Frameworks SubTopic: UIKit Tags:
Aug ’21
Reply to DateComponents configuration for x months
Thanks. The explanation in doc is not very clear. But seems coherent with my understanding. And the Xcode doc for UNCalendarNotificationTrigger confirms Overview Create a UNCalendarNotificationTrigger object when you want to schedule the delivery of a local notification at the specified date and time. You specify the temporal information using an NSDateComponents object, which lets you specify only the time values that matter to you. The system uses the provided information to determine the next date and time that matches the specified information. Listing 1 creates a trigger that delivers its notification every morning at 8:30. The repeating behavior is achieved by specifying true for the repeats parameter when creating the trigger. Listing 1 Creating a trigger that repeats at a specific time var date = DateComponents() date.hour = 8 date.minute = 30 let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true)   I don't know how to do directly what you want. A workaround would be to create multiple notifications, as described here: https://stackoverflow.com/questions/50027190/uncalendarnotificationtrigger-every-3rd-day
Aug ’21
Reply to Implement vibrancy on NSTextField
What is it that you can't make work ? Is it for MacOS ? Here is for iOS (and objC), but adaptation should be easy: https://stackoverflow.com/questions/26265936/uitextfield-placeholder-with-vibrancy But consider this note from NSVisualEffectView doc in Xcode: Note AppKit views and controls automatically add vibrancy where appropriate. For example, NSTextField enables vibrancy to increase the contrast between the text and background. Don't change the vibrancy settings of standard AppKit views and controls.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Does Apple allow an app that has a log-in feature without a sign-up feature on App Store?
My understanding is that you don't need Apple sign-in in this case. Here are what guidelines say: 4.8 Sign in with Apple Apps that use a third-party or social login service (such as Facebook Login, Google Sign-In, Sign in with Twitter, Sign In with LinkedIn, Login with Amazon, or WeChat Login) to set up or authenticate the user’s primary account with the app must also offer Sign in with Apple as an equivalent option. A user’s primary account is the account they establish with your app for the purposes of identifying themselves, signing in, and accessing your features and associated services. Sign in with Apple is not required if: Your app exclusively uses your company’s own account setup and sign-in systems. Your app is an education, enterprise, or business app that requires the user to sign in with an existing education or enterprise account. Your app uses a government or industry-backed citizen identification system or electronic ID to authenticate users. Your app is a client for a specific third-party service and users are required to sign in to their mail, social media, or other third-party account directly to access their content. Looks like you're in the first or fourth case
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Image Classification Data
Not sure I understand your question. Could these tutorials help you? https://developer.apple.com/documentation/createml/creating_an_image_classifier_model or h t t p s : / / w w w .raywenderlich.com/7960296-core-ml-and-vision-tutorial-on-device-training-on-ios Otrherwise, please explain more what is your problem.
Aug ’21
Reply to Hi I am getting a blank screen when I run the following code in my Xcode project
Is it the real code ? It cannot compile. This is not correct syntax:    @State private var articles = [ Article () It misses closing bracket    @State private var articles = [Article] () And there is an extra quote and probably backslash here:       print ("Error: `(error?.localizedDescription` ?? "Unknown Error") ") Should be             print ("Error: \(error?.localizedDescription ?? "Unknown Error") ") I modified the code as follows import SwiftUI struct Result: Codable { var articles: [Article] } struct Article: Codable, Hashable { // Hashable to be able to use \.self in List var url: String var title: String var description: String? var urlToImage: String? } struct ContentView: View { private let url = "https://newsapi.org/v2/top-headlines?country=us&category=business&apiKey=49d5bfa113c34ec0af781fab38395996" @State private var articles : [Article] = [] // Just for the forum editor func fetchData() { guard let url = URL(string: url) else { print("URL is not valid") return } let request = URLRequest(url: url) URLSession.shared.dataTask(with: request) { data, response, error in if let data = data { if let decodedResult = try? JSONDecoder().decode( Result.self, from: data) { DispatchQueue.main.async { self.articles = decodedResult.articles print("Articles", articles) } return } } print ("Error: \(error?.localizedDescription ?? "Unknown Error") ") }.resume() } var body: some View { VStack { // Just to get something on screen List(articles, id: \.self) { item in HStack(alignment: .top) { VStack(alignment: .leading) { Text(item.title) .font(.headline) Text(item.description ?? "") .font(.footnote) } }.onAppear(perform: fetchData) } Text("Count articles \(articles.count)") } } } You get 0 article: which means Article and JSON may not match (I did not inspect the JSON file). I tested with an explicit int(), removing onAppear. Same issue: init() {     self.fetchData() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’21
Reply to Presentation single with code
Could you explain better what you get and what you want ? I try to formulate You click button, calling obrirAmbCodi, which opens a window finestra3 when you click again on that button, a new, similar window opens (probably stacked over previous one ?) in such a case, you would want just to display the already opened window, not create a new one. Is that correct ? If so, you could: In the class where obrirAmbCodi is, declare a var var controller: NSWindowController? test if nil ; if so instantiate     @IBAction func obrirAmbCodi(_ sender: NSButton) { if controller == nil {         let storyboard:NSStoryboard = NSStoryboard(name: "Main", bundle: nil) controller = storyboard.instantiateController(withIdentifier: "finestra3") as? NSWindowController // could be nil             controller?.showWindow(self) }     } dismiss the controller when you close window and set to nil Note: you could test if the window is open instead of testing controller
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Adding Restores Everything
The thing is I need noRepFav because I don't want duplicates in my array. There are very simple ways to achieve this with a single array. Before appending to this array, check if the item already exist. I'm confused with this code: you have at least 2 different TableViewControllers (FavouritesVC, HockeyDetailVC). Both of them have handleFavNotification. It is not clear where you delete, where you add, where it is added back.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Override info.plist value at runtime
You cannot do that. info.plist is part of bundle and cannot be changed at runtime. See details here for instance: https://stackoverflow.com/questions/40214673/setting-value-to-info-plist-file-from-swift?noredirect=1&lq=1 But why change the info.plist and not directly the appearance ? https://developer.apple.com/documentation/appkit/nsappearancecustomization/choosing_a_specific_appearance_for_your_macos_app
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to withThrowingTaskGroup - (un)expected progress behavior?
I probably miss something obvious. But why don't you increment counter in the for idx loop ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to thread 8: fatal error
Because you have an error in your code ! Which crashes in thread 8. How do you want we guess where it could come from if you do not show the code where it occurs ?
Replies
Boosts
Views
Activity
Aug ’21
Reply to Xcode Swift Coremotion Pedometer update every step
AFAIK, answer is no. A few reference material: https://stackoverflow.com/questions/36439912/live-updates-with-cmpedometer-coremotion h t t p s : / / medium.com/simform-engineering/count-steps-with-cmpedometer-on-iwatch-94b61bc3b87e The pedometer is a higher level object on Core motion. It sets its own refresh rates and we can get updates through a closure, so it’s on its own schedule, not one we can control. Just an idea, for what it's worth. Using the actual speed and the recent ratio steps/speed, maybe you could estimate the count at the frequency you want, and display it. Then, as soon as you receive a new pedometer information, update everything. I don't know if that would be good enough or too chaotic information display.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to boundingRectWithSize returns different values in iOS15
Do you use the same font "PingFangSC-Regular" in both cases ? NSStringDrawingUsesFontLeading doc says Uses the font leading for calculating line heights. I don't know if this value or this computation has changed in iOS 15. I would advise to file a bug report.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Navigation Controller Back Button not working correctly when tapped
No, never met this problem. Could you tell: Which version of Xcode ? On simulator or device ? Which OS version in anycase. Have you changed the button programmatically, in anyway ? Are you sure you have nothing overplayed over "Back" ? Could debug view hierarchy when running to check for this ? Eventually, create the smallest possible project to reproduce and attach the full project folder here.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to DateComponents configuration for x months
Thanks. The explanation in doc is not very clear. But seems coherent with my understanding. And the Xcode doc for UNCalendarNotificationTrigger confirms Overview Create a UNCalendarNotificationTrigger object when you want to schedule the delivery of a local notification at the specified date and time. You specify the temporal information using an NSDateComponents object, which lets you specify only the time values that matter to you. The system uses the provided information to determine the next date and time that matches the specified information. Listing 1 creates a trigger that delivers its notification every morning at 8:30. The repeating behavior is achieved by specifying true for the repeats parameter when creating the trigger. Listing 1 Creating a trigger that repeats at a specific time var date = DateComponents() date.hour = 8 date.minute = 30 let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true)   I don't know how to do directly what you want. A workaround would be to create multiple notifications, as described here: https://stackoverflow.com/questions/50027190/uncalendarnotificationtrigger-every-3rd-day
Replies
Boosts
Views
Activity
Aug ’21
Reply to Implement vibrancy on NSTextField
What is it that you can't make work ? Is it for MacOS ? Here is for iOS (and objC), but adaptation should be easy: https://stackoverflow.com/questions/26265936/uitextfield-placeholder-with-vibrancy But consider this note from NSVisualEffectView doc in Xcode: Note AppKit views and controls automatically add vibrancy where appropriate. For example, NSTextField enables vibrancy to increase the contrast between the text and background. Don't change the vibrancy settings of standard AppKit views and controls.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Does Apple allow an app that has a log-in feature without a sign-up feature on App Store?
My understanding is that you don't need Apple sign-in in this case. Here are what guidelines say: 4.8 Sign in with Apple Apps that use a third-party or social login service (such as Facebook Login, Google Sign-In, Sign in with Twitter, Sign In with LinkedIn, Login with Amazon, or WeChat Login) to set up or authenticate the user’s primary account with the app must also offer Sign in with Apple as an equivalent option. A user’s primary account is the account they establish with your app for the purposes of identifying themselves, signing in, and accessing your features and associated services. Sign in with Apple is not required if: Your app exclusively uses your company’s own account setup and sign-in systems. Your app is an education, enterprise, or business app that requires the user to sign in with an existing education or enterprise account. Your app uses a government or industry-backed citizen identification system or electronic ID to authenticate users. Your app is a client for a specific third-party service and users are required to sign in to their mail, social media, or other third-party account directly to access their content. Looks like you're in the first or fourth case
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to iPhone 11 lag
That's not an issue for developer forum (unless you develop the game 😉). Contact directly the game developer or look on its forum. Or post a question to Apple support. Good play.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to VM - Compressor failed a blocking pager_get
There was a similar issue posted :   https://developer.apple.com/forums/thread/687954 You should file a bug report as well and report the FB number here.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Image Classification Data
Not sure I understand your question. Could these tutorials help you? https://developer.apple.com/documentation/createml/creating_an_image_classifier_model or h t t p s : / / w w w .raywenderlich.com/7960296-core-ml-and-vision-tutorial-on-device-training-on-ios Otrherwise, please explain more what is your problem.
Replies
Boosts
Views
Activity
Aug ’21
Reply to Hi I am getting a blank screen when I run the following code in my Xcode project
Is it the real code ? It cannot compile. This is not correct syntax:    @State private var articles = [ Article () It misses closing bracket    @State private var articles = [Article] () And there is an extra quote and probably backslash here:       print ("Error: `(error?.localizedDescription` ?? "Unknown Error") ") Should be             print ("Error: \(error?.localizedDescription ?? "Unknown Error") ") I modified the code as follows import SwiftUI struct Result: Codable { var articles: [Article] } struct Article: Codable, Hashable { // Hashable to be able to use \.self in List var url: String var title: String var description: String? var urlToImage: String? } struct ContentView: View { private let url = "https://newsapi.org/v2/top-headlines?country=us&category=business&apiKey=49d5bfa113c34ec0af781fab38395996" @State private var articles : [Article] = [] // Just for the forum editor func fetchData() { guard let url = URL(string: url) else { print("URL is not valid") return } let request = URLRequest(url: url) URLSession.shared.dataTask(with: request) { data, response, error in if let data = data { if let decodedResult = try? JSONDecoder().decode( Result.self, from: data) { DispatchQueue.main.async { self.articles = decodedResult.articles print("Articles", articles) } return } } print ("Error: \(error?.localizedDescription ?? "Unknown Error") ") }.resume() } var body: some View { VStack { // Just to get something on screen List(articles, id: \.self) { item in HStack(alignment: .top) { VStack(alignment: .leading) { Text(item.title) .font(.headline) Text(item.description ?? "") .font(.footnote) } }.onAppear(perform: fetchData) } Text("Count articles \(articles.count)") } } } You get 0 article: which means Article and JSON may not match (I did not inspect the JSON file). I tested with an explicit int(), removing onAppear. Same issue: init() {     self.fetchData() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21