Post

Replies

Boosts

Views

Activity

Reply to Permission to bulk operate on other apps
You can post a FeedBack assistant (bug report) asking for enhancement. But I do think you can get no satisfaction 😉. As Scott J said, that would go against a long time policy to forbid an app to play with other apps or with system behaviour (for instance it is not possible to change the functions of buttons).
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to ProgressBar with DispatchQueue
You have to create a MacOS playground. This works in such a playground (note that I had to make a few corrections): import Dispatch import Foundation var comboCount:NSKeyValueObservation? class viewContr: NSViewController { @IBOutlet weak var progressBar: NSProgressIndicator! // deinit { comboCount?.invalidate() } @IBAction func calcStuff(_ sender: NSButton) { DispatchQueue.global(qos: .userInitiated).async { let combos = possibleCombos() DispatchQueue.main.async { for word in combos { word.print0b8() } } } } } func possibleCombos() -> [Int8] { var combos = [Int8] () for a in [0, 1] { for b in [0, 1] { for c in [0, 1] { for d in [0, 1] { combos.append(Int8(d | (c << 1) | (b << 2) | (a << 3)) ) comboCount = combos.count/16 as! NSKeyValueObservation // known total combos = 16 // How do I pass combos.count out to a progress bar? } } } } return combos } extension Int8 {func print0b8() {print("0b" + pad(string: String(self, radix: 2), toSize: 4))}} func pad(string : String, toSize: Int) -> String {var padded = string;for _ in 0..<(toSize - string.count) {padded = "0" + padded};return padded} I tested the following in app class viewContr: NSViewController { var comboCount: Int = 0 // NSKeyValueObservation? var when = DispatchTime.now() @IBOutlet weak var progressBar: NSProgressIndicator! // deinit { comboCount?.invalidate() } @IBAction func calcStuff(_ sender: NSButton) { DispatchQueue.global(qos: .userInitiated).async {[self] in let combos = possibleCombos() DispatchQueue.main.asyncAfter(deadline: when) { print(combos.count) for word in combos { word.print0b8() } } } } func possibleCombos() -> [Int8] { var combos = [Int8] () when = DispatchTime.now() for a in [0, 1] { for b in [0, 1] { for c in [0, 1] { for d in [0, 1] { DispatchQueue.global().asyncAfter(deadline: when) {[self] in combos.append(Int8(d | (c << 1) | (b << 2) | (a << 3)) ) comboCount = (100 * combos.count) / 16 // as! NSKeyValueObservation DispatchQueue.main.async { [self] in progressBar.doubleValue = Double(comboCount) } // known total combos = 16 // How do I pass combos.count out to a progress bar? } when = when + .milliseconds(200) } } } } return combos } } Indicator (determinate) works ok. There is a problem to fix word.print0b8() because it has only one item when printing. Some dispatch to adjust. A solution would be to move it inside the possibleCombos() But now, you should do it with async-await pattern.
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to ProgressBar with DispatchQueue
I will try this change: for d in [0, 1] { combos.append(Int8(d | (c << 1) | (b << 2) | (a << 3)) ) comboCount = (100 * combos.count) / 16 // as! NSKeyValueObservation DispatchQueue.global().asyncAfter(deadline: when) {[self] in
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to controlTextDidEndEditing for View Based NSTableView
Yes, I usually set tags:     func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { // … code                 cellView.textField!.tag = row + 256 * column. // If less than 256 rows ; otherwise         cellView.textField!.tag = row + 256 * column This is a multiplexed value of row and col. I attach an IBAction to the tableViewCell: @IBAction func cellContentDidChange(_ sender: NSTextField) { // Let's find row and coll by demuxing the tag let rowIndiv = highWordTag % 256 let colVar = (sender.tag - rowIndiv) / 256 (that's Swift, but easily adaptable to objC)
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to ProgressBar with DispatchQueue
This now works. No more dispatch in calc. For sure, code could be improved, but that's a way to get it working. class viewContr: NSViewController { var comboCount: Int = 0 // NSKeyValueObservation? var when = DispatchTime.now() @IBOutlet weak var progressBar: NSProgressIndicator! @IBAction func calcStuff(_ sender: NSButton) { DispatchQueue.global(qos: .userInitiated).async {[self] in let combos = possibleCombos() // DispatchQueue.main.asyncAfter(deadline: when) { for word in combos { word.print0b8() } // } } } func possibleCombos() -> [Int8] { var combos = [Int8] () var combosForDisplay = combos // That's the way to get value both for return and for progress when = DispatchTime.now() for a in [0, 1] { for b in [0, 1] { for c in [0, 1] { for d in [0, 1] { let value = Int8(d | (c << 1) | (b << 2) | (a << 3)) combos.append(value ) DispatchQueue.global().asyncAfter(deadline: when) {[self] in combosForDisplay.append(value) // Do it again ; otherwise we capture the wrong value from combos comboCount = (100 * combosForDisplay.count) / 16 // as! NSKeyValueObservation print(comboCount, when) DispatchQueue.main.async { [self] in progressBar.doubleValue = Double(comboCount) } // known total combos = 16 // How do I pass combos.count out to a progress bar? } when = when + .milliseconds(300) } } } } return combos } } extension Int8 {func print0b8() {print("0b" + pad(string: String(self, radix: 2), toSize: 4))}} func pad(string : String, toSize: Int) -> String {var padded = string;for _ in 0..<(toSize - string.count) {padded = "0" + padded};return padded}
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to How do I get the emoji Title and Description to show from array?
When you paste code, please use Paste and Match Style to avoid all the extra lines. In addition, you should provide all the elements to allow to test code. how is randomEmojiImage defined ? what is wave ? it keeps throwing an error Please tell exactly which error, and where precisely. struct ContentView: View { @State private var title = randomEmojiImage.randomElement() ?? "👋" @State private var titlePlace = Text("") @State private var descript = Text("\(switching())") func switching(){ if title == "👋" { let titlePlace = Text("\(wave.Title)") let descript = Text("\(wave.Description)") } else if title == "✌️" { let titlePlace = Text("\(peace.Title)") let descript = Text("\(peace.Description)") } else if title == "😀" { let titlePlace = Text("\(happy.Title)") let descript = Text("\(happy.Description)") } else if title == "💩" { let titlePlace = Text("\(****.Title)") let descript = Text("\(****.Description)") } else if title == "😢" { let titlePlace = Text("\(sad.Title)") let descript = Text("\(sad.Description)") } } var body: some View { VStack { Text("\(title)") .font(.system(size: 80)) .padding() Text("\(titlePlace)") .padding() Text("\(descript)") } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView1() } } There are plenty of problems here. Go and learn how to use @State var. Text() is a view, not a String: you cannot assign it to titlePlace You cannot call switching() to initialise the var ; this call should be done when you elsewhere (when do you want to switch ? When hitting a button ?) take care that var should start with lowerCase. And cannot be **** This is a partially corrected code, but I miss information to complete. struct Behavior { var title = "" var description = "" } struct ContentView1: View { let randomEmojiImage = ["👋", "✌️", "😀", "💩", "😢"] @State private var title = "👋" <:: randomEmojiImage.randomElement() ?? "👋" @State private var titlePlace = "" @State private var descript = "" func switching(){ let wave = Behavior(title: "wave", description: "wave") let peace = Behavior(title: "peace", description: "peace") let happy = Behavior(title: "happy", description: "happy") let stars = Behavior(title: "****", description: "****") let sad = Behavior(title: "sad", description: "sad") if title == "👋" { let titlePlace = wave.title let descript = wave.description } else if title == "✌️" { let titlePlace = peace.title let descript = peace.description } else if title == "😀" { let titlePlace = happy.title let descript = happy.description } else if title == "💩" { let titlePlace = stars.title let descript = stars.description } else if title == "😢" { let titlePlace = sad.title let descript = sad.description } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to Photo
Do you want to add a photo in the project ? If I understood your question: that must be a png copy the photo in the project in the Finder (to be sure it stays in a stable location): not compulsory, but I find it a good practice then drag this photo in the file navigator (left panel) select copyItem if needed
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to TabBar 2 clicks
I created a dummy app to test. Open the app I get the 4 tabs + … tab Hit the … tab, nothing happens - not even blink Hit again, then get the list to choose Now, each time I tap …, I go to the page Second test I open the app Hit any tab (except …) if I hit the … tab, I get the list to choose immediately So the problem is when the first tab ever hit is the … tab. Looks like a bug. I tested also in an UIKit app. When I hit more, I get immediately a list to choose the destination (5 or 6).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to We have recently been advised that payments to your content provider account are on hold
It is likely a scam, as Apple knows your bank account. Others received the same (I see you saw this thread): https://developer.apple.com/forums/thread/669413 You should contact Apple support for double check and let them know about this. Did you contact your bank ? If that were real, they would likely have informed you before informing Apple !
Nov ’21
Reply to is the apple developer license free
You can become Apple Developer for free, that allows to get tools, download app on your iPhone (need to rebuild after a week). But you cannot distribute app on the AppStore. The 2 status are: ADP: Apple Developer Program membership. Members of this paid program can distribute apps on the App Store. Apple Developer: Apple ID holders who have agreed to the Apple Developer Agreement to access certain resources on the Apple Developer website. No cost is associated with this agreement and developers cannot distribute apps. Get more details here: https://developer.apple.com/forums/thread/53048 and more precisely: https://help.apple.com/developer-account/#/dev21218dfd6
Nov ’21
Reply to Permission to bulk operate on other apps
You can post a FeedBack assistant (bug report) asking for enhancement. But I do think you can get no satisfaction 😉. As Scott J said, that would go against a long time policy to forbid an app to play with other apps or with system behaviour (for instance it is not possible to change the functions of buttons).
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to SafeArea breaks after device orientation change
Could you show the exact code for where you use Screen.safeArea (the calling func)? I probably miss something, but I cannot find safeArea in doc.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to ProgressBar with DispatchQueue
You have to create a MacOS playground. This works in such a playground (note that I had to make a few corrections): import Dispatch import Foundation var comboCount:NSKeyValueObservation? class viewContr: NSViewController { @IBOutlet weak var progressBar: NSProgressIndicator! // deinit { comboCount?.invalidate() } @IBAction func calcStuff(_ sender: NSButton) { DispatchQueue.global(qos: .userInitiated).async { let combos = possibleCombos() DispatchQueue.main.async { for word in combos { word.print0b8() } } } } } func possibleCombos() -> [Int8] { var combos = [Int8] () for a in [0, 1] { for b in [0, 1] { for c in [0, 1] { for d in [0, 1] { combos.append(Int8(d | (c << 1) | (b << 2) | (a << 3)) ) comboCount = combos.count/16 as! NSKeyValueObservation // known total combos = 16 // How do I pass combos.count out to a progress bar? } } } } return combos } extension Int8 {func print0b8() {print("0b" + pad(string: String(self, radix: 2), toSize: 4))}} func pad(string : String, toSize: Int) -> String {var padded = string;for _ in 0..<(toSize - string.count) {padded = "0" + padded};return padded} I tested the following in app class viewContr: NSViewController { var comboCount: Int = 0 // NSKeyValueObservation? var when = DispatchTime.now() @IBOutlet weak var progressBar: NSProgressIndicator! // deinit { comboCount?.invalidate() } @IBAction func calcStuff(_ sender: NSButton) { DispatchQueue.global(qos: .userInitiated).async {[self] in let combos = possibleCombos() DispatchQueue.main.asyncAfter(deadline: when) { print(combos.count) for word in combos { word.print0b8() } } } } func possibleCombos() -> [Int8] { var combos = [Int8] () when = DispatchTime.now() for a in [0, 1] { for b in [0, 1] { for c in [0, 1] { for d in [0, 1] { DispatchQueue.global().asyncAfter(deadline: when) {[self] in combos.append(Int8(d | (c << 1) | (b << 2) | (a << 3)) ) comboCount = (100 * combos.count) / 16 // as! NSKeyValueObservation DispatchQueue.main.async { [self] in progressBar.doubleValue = Double(comboCount) } // known total combos = 16 // How do I pass combos.count out to a progress bar? } when = when + .milliseconds(200) } } } } return combos } } Indicator (determinate) works ok. There is a problem to fix word.print0b8() because it has only one item when printing. Some dispatch to adjust. A solution would be to move it inside the possibleCombos() But now, you should do it with async-await pattern.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to ProgressBar with DispatchQueue
I will try this change: for d in [0, 1] { combos.append(Int8(d | (c << 1) | (b << 2) | (a << 3)) ) comboCount = (100 * combos.count) / 16 // as! NSKeyValueObservation DispatchQueue.global().asyncAfter(deadline: when) {[self] in
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to controlTextDidEndEditing for View Based NSTableView
Yes, I usually set tags:     func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { // … code                 cellView.textField!.tag = row + 256 * column. // If less than 256 rows ; otherwise         cellView.textField!.tag = row + 256 * column This is a multiplexed value of row and col. I attach an IBAction to the tableViewCell: @IBAction func cellContentDidChange(_ sender: NSTextField) { // Let's find row and coll by demuxing the tag let rowIndiv = highWordTag % 256 let colVar = (sender.tag - rowIndiv) / 256 (that's Swift, but easily adaptable to objC)
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to ProgressBar with DispatchQueue
This now works. No more dispatch in calc. For sure, code could be improved, but that's a way to get it working. class viewContr: NSViewController { var comboCount: Int = 0 // NSKeyValueObservation? var when = DispatchTime.now() @IBOutlet weak var progressBar: NSProgressIndicator! @IBAction func calcStuff(_ sender: NSButton) { DispatchQueue.global(qos: .userInitiated).async {[self] in let combos = possibleCombos() // DispatchQueue.main.asyncAfter(deadline: when) { for word in combos { word.print0b8() } // } } } func possibleCombos() -> [Int8] { var combos = [Int8] () var combosForDisplay = combos // That's the way to get value both for return and for progress when = DispatchTime.now() for a in [0, 1] { for b in [0, 1] { for c in [0, 1] { for d in [0, 1] { let value = Int8(d | (c << 1) | (b << 2) | (a << 3)) combos.append(value ) DispatchQueue.global().asyncAfter(deadline: when) {[self] in combosForDisplay.append(value) // Do it again ; otherwise we capture the wrong value from combos comboCount = (100 * combosForDisplay.count) / 16 // as! NSKeyValueObservation print(comboCount, when) DispatchQueue.main.async { [self] in progressBar.doubleValue = Double(comboCount) } // known total combos = 16 // How do I pass combos.count out to a progress bar? } when = when + .milliseconds(300) } } } } return combos } } extension Int8 {func print0b8() {print("0b" + pad(string: String(self, radix: 2), toSize: 4))}} func pad(string : String, toSize: Int) -> String {var padded = string;for _ in 0..<(toSize - string.count) {padded = "0" + padded};return padded}
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to How do I get the emoji Title and Description to show from array?
When you paste code, please use Paste and Match Style to avoid all the extra lines. In addition, you should provide all the elements to allow to test code. how is randomEmojiImage defined ? what is wave ? it keeps throwing an error Please tell exactly which error, and where precisely. struct ContentView: View { @State private var title = randomEmojiImage.randomElement() ?? "👋" @State private var titlePlace = Text("") @State private var descript = Text("\(switching())") func switching(){ if title == "👋" { let titlePlace = Text("\(wave.Title)") let descript = Text("\(wave.Description)") } else if title == "✌️" { let titlePlace = Text("\(peace.Title)") let descript = Text("\(peace.Description)") } else if title == "😀" { let titlePlace = Text("\(happy.Title)") let descript = Text("\(happy.Description)") } else if title == "💩" { let titlePlace = Text("\(****.Title)") let descript = Text("\(****.Description)") } else if title == "😢" { let titlePlace = Text("\(sad.Title)") let descript = Text("\(sad.Description)") } } var body: some View { VStack { Text("\(title)") .font(.system(size: 80)) .padding() Text("\(titlePlace)") .padding() Text("\(descript)") } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView1() } } There are plenty of problems here. Go and learn how to use @State var. Text() is a view, not a String: you cannot assign it to titlePlace You cannot call switching() to initialise the var ; this call should be done when you elsewhere (when do you want to switch ? When hitting a button ?) take care that var should start with lowerCase. And cannot be **** This is a partially corrected code, but I miss information to complete. struct Behavior { var title = "" var description = "" } struct ContentView1: View { let randomEmojiImage = ["👋", "✌️", "😀", "💩", "😢"] @State private var title = "👋" <:: randomEmojiImage.randomElement() ?? "👋" @State private var titlePlace = "" @State private var descript = "" func switching(){ let wave = Behavior(title: "wave", description: "wave") let peace = Behavior(title: "peace", description: "peace") let happy = Behavior(title: "happy", description: "happy") let stars = Behavior(title: "****", description: "****") let sad = Behavior(title: "sad", description: "sad") if title == "👋" { let titlePlace = wave.title let descript = wave.description } else if title == "✌️" { let titlePlace = peace.title let descript = peace.description } else if title == "😀" { let titlePlace = happy.title let descript = happy.description } else if title == "💩" { let titlePlace = stars.title let descript = stars.description } else if title == "😢" { let titlePlace = sad.title let descript = sad.description } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to No basic localization applied
Expect to see English,  Why ? What are the preferred languages in iOS settings ? If French comes before english, it will display in french. You should have something like this: You reorder by dragging with the right handle in the cells.
Replies
Boosts
Views
Activity
Nov ’21
Reply to Photo
Do you want to add a photo in the project ? If I understood your question: that must be a png copy the photo in the project in the Finder (to be sure it stays in a stable location): not compulsory, but I find it a good practice then drag this photo in the file navigator (left panel) select copyItem if needed
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Doubt about initializers and super.init() in NSView
Why do you need this init ? The only initialisers for NSView are: NSView() NSView(coder:) NSView(frame:)        And there is no Binding in the SO reference…
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to TabBar 2 clicks
I created a dummy app to test. Open the app I get the 4 tabs + … tab Hit the … tab, nothing happens - not even blink Hit again, then get the list to choose Now, each time I tap …, I go to the page Second test I open the app Hit any tab (except …) if I hit the … tab, I get the list to choose immediately So the problem is when the first tab ever hit is the … tab. Looks like a bug. I tested also in an UIKit app. When I hit more, I get immediately a list to choose the destination (5 or 6).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to We have recently been advised that payments to your content provider account are on hold
It is likely a scam, as Apple knows your bank account. Others received the same (I see you saw this thread): https://developer.apple.com/forums/thread/669413 You should contact Apple support for double check and let them know about this. Did you contact your bank ? If that were real, they would likely have informed you before informing Apple !
Replies
Boosts
Views
Activity
Nov ’21
Reply to Navigation Bar Color
Slightly different: could you be more specific ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to SF Symbols Fill
I get the same wrong behaviour: Tab3View() .tabItem { Image(systemName: "book") // 3.circle.fill") Text("Tab3") } gives But in UIKit, I get: So that feels like a bug.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to is the apple developer license free
You can become Apple Developer for free, that allows to get tools, download app on your iPhone (need to rebuild after a week). But you cannot distribute app on the AppStore. The 2 status are: ADP: Apple Developer Program membership. Members of this paid program can distribute apps on the App Store. Apple Developer: Apple ID holders who have agreed to the Apple Developer Agreement to access certain resources on the Apple Developer website. No cost is associated with this agreement and developers cannot distribute apps. Get more details here: https://developer.apple.com/forums/thread/53048 and more precisely: https://help.apple.com/developer-account/#/dev21218dfd6
Replies
Boosts
Views
Activity
Nov ’21