Post

Replies

Boosts

Views

Activity

Reply to Xcode 13 beta 3 - should it create Localizable.strings file for the base languge?
I usually have both the base language and a file for any language (including base: hence it will show twice). For adding manually a new language, I usually do it directly in Finder before dragging into the project (with some care depending on what type of file it is). I've written a document (in french) for my own use that I could share if you post an email address where to send.
Jul ’21
Reply to Editor placeholder in source file
When you post code, don't post in comments. It is totally messed up. Here it is formatted: class ViewController: UIViewController, UITextFieldDelegate { @IBOutlet weak var benchPressPB: UITextField! @IBOutlet weak var squatPB: UITextField! @IBOutlet weak var deadliftPB: UITextField! @IBOutlet weak var ohpPB: UITextField! @IBOutlet weak var rackPullPB: UITextField! @IBOutlet weak var legPressPB: UITextField! @IBOutlet weak var pullUpsPB: UITextField! var textFields = var textFieldKeys = [ "benchPressPB", "squatPB", "deadliftPB", "ohpPB", "rackPullPB", "legPressPB", "pullUpsPB" ] var textFieldStrings = override func viewDidLoad() { super.viewDidLoad() self.benchPressPB.delegate = self self.squatPB.delegate = self self.deadliftPB.delegate = self self.ohpPB.delegate = self self.rackPullPB.delegate = self self.legPressPB.delegate = self self.pullUpsPB.delegate = self textFields = [benchPressPB, squatPB, deadliftPB, ohpPB, rackPullPB, legPressPB, pullUpsPB] for (index, key) in textFieldKeys.enumerated() { let aValue = UserDefaults.standard.string(forKey: key) textFields[index].text = aValue textFieldStrings.append(aValue ?? "") } } func textFieldShouldReturn(_ textField: UITextField) -> Bool { textField.resignFirstResponder() let newText = textField.text if let index = textFields.firstIndex(of: textField) { textFieldStrings[index] = newText UserDefaults.standard.set(newText, forKey: textFieldKeys[index]) } return true } } // My full code for my app, to provide a new default value, do I first need to declare it as a variable? or am I completely missing the point. Apologies if this is a completely dumb question. I am literally brand new to this and was advised the best way to learn was to just build something instead of a boring udemy course. I had to delete some of the code to post... UITextFields() & UIString() Really appreciate all your help! There is something that doesn't mean anything:  var textFields =   var textFieldKeys = [    "benchPressPB",    "squatPB",    "deadliftPB",    "ohpPB",    "rackPullPB",    "legPressPB",    "pullUpsPB"   ]    var textFieldStrings = The error here: if let index = textFields.firstIndex(of: textField) { textFieldStrings[index] = newText UserDefaults.standard.set(newText, forKey: textFieldKeys[index]) } textField is UITextField ; textFields is an array of String (I assume) So you should search for newText. But it is an optional, you need to unwrap first if let newText = textField.text, let index = textFields.firstIndex(of: newText) {
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’21
Reply to Need Help Transfer Data From Button
It's risky to have dataSource as a Set, because order will change. Don't you mind ? Anyway, just replace selectedNameInCell = dataSource[indexPath.row].yahooName with override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { if let cell = cellForRow(at: IndexPath) { selectedNameInCell = cell.yahooName // I assume you have such a property in the cell ; or maybe it is just cell.textLabel!.text if the name is the textLabel } }
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Need Help Transfer Data From Button
I wanted to avoid duplicates with an array. Yes, that's logical, but you should handle it when you populate the array. Or remove any duplicate in the array: var myArray = [/* Some items*/] var noReplicateArray = [] // with same types of items for item in myArray { if !noReplicateArray.contains(item) { noReplicateArray.append(item) } } You can also use reduce: noReplicateArray = myArray.reduce([]) {array, item in if array.contains(item) { return array } else { return array+[item] } } But the first appears to be much faster.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Is the result of Pegasus embedded in my phone or some different forensic software?
If you've really been hacked by Pegasus : bad news, your phone is compromised. Good news: you are among the 50000 most important people on earth😊… More seriously, a lot has been published on how to detect if infected (need to use Terminal). Note: I doubt the Pegasus you see here is the same. Would be really surprising for it to leave its full name here !
Jul ’21
Reply to Xcode 13 beta 3 - should it create Localizable.strings file for the base languge?
I usually have both the base language and a file for any language (including base: hence it will show twice). For adding manually a new language, I usually do it directly in Finder before dragging into the project (with some care depending on what type of file it is). I've written a document (in french) for my own use that I could share if you post an email address where to send.
Replies
Boosts
Views
Activity
Jul ’21
Reply to JSONDecoder Limit
I just tested in Xcode 13ß4. No more crash. Playground bug is apparently corrected.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Why is this clearing?
Clearing what ? What makes you crazy ? What is the point that doesn't work or that you don't understand ?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Emulate double leftclick on MacOS
Did you try posting events twice ?        eventDown?.post(tap: .cghidEventTap)        eventUp?.post(tap: .cghidEventTap)       eventDown?.post(tap: .cghidEventTap)        eventUp?.post(tap: .cghidEventTap)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Emulate double leftclick on MacOS
Could you test how many events were received, using: class func counterForEventType(_ stateID: CGEventSourceStateID, eventType: CGEventType) -> UInt32
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Emulate double leftclick on MacOS
Could you try to move the mouse by a few pixels, so that it is not the exact same event but still in the limits for double click ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Emulate double leftclick on MacOS
My point is that you post the same event:         eventDown?.post(tap: .cghidEventTap) I propose to create 2 events: eventDown1 and eventDown2.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Editor placeholder in source file
When you post code, don't post in comments. It is totally messed up. Here it is formatted: class ViewController: UIViewController, UITextFieldDelegate { @IBOutlet weak var benchPressPB: UITextField! @IBOutlet weak var squatPB: UITextField! @IBOutlet weak var deadliftPB: UITextField! @IBOutlet weak var ohpPB: UITextField! @IBOutlet weak var rackPullPB: UITextField! @IBOutlet weak var legPressPB: UITextField! @IBOutlet weak var pullUpsPB: UITextField! var textFields = var textFieldKeys = [ "benchPressPB", "squatPB", "deadliftPB", "ohpPB", "rackPullPB", "legPressPB", "pullUpsPB" ] var textFieldStrings = override func viewDidLoad() { super.viewDidLoad() self.benchPressPB.delegate = self self.squatPB.delegate = self self.deadliftPB.delegate = self self.ohpPB.delegate = self self.rackPullPB.delegate = self self.legPressPB.delegate = self self.pullUpsPB.delegate = self textFields = [benchPressPB, squatPB, deadliftPB, ohpPB, rackPullPB, legPressPB, pullUpsPB] for (index, key) in textFieldKeys.enumerated() { let aValue = UserDefaults.standard.string(forKey: key) textFields[index].text = aValue textFieldStrings.append(aValue ?? "") } } func textFieldShouldReturn(_ textField: UITextField) -> Bool { textField.resignFirstResponder() let newText = textField.text if let index = textFields.firstIndex(of: textField) { textFieldStrings[index] = newText UserDefaults.standard.set(newText, forKey: textFieldKeys[index]) } return true } } // My full code for my app, to provide a new default value, do I first need to declare it as a variable? or am I completely missing the point. Apologies if this is a completely dumb question. I am literally brand new to this and was advised the best way to learn was to just build something instead of a boring udemy course. I had to delete some of the code to post... UITextFields() & UIString() Really appreciate all your help! There is something that doesn't mean anything:  var textFields =   var textFieldKeys = [    "benchPressPB",    "squatPB",    "deadliftPB",    "ohpPB",    "rackPullPB",    "legPressPB",    "pullUpsPB"   ]    var textFieldStrings = The error here: if let index = textFields.firstIndex(of: textField) { textFieldStrings[index] = newText UserDefaults.standard.set(newText, forKey: textFieldKeys[index]) } textField is UITextField ; textFields is an array of String (I assume) So you should search for newText. But it is an optional, you need to unwrap first if let newText = textField.text, let index = textFields.firstIndex(of: newText) {
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
It's risky to have dataSource as a Set, because order will change. Don't you mind ? Anyway, just replace selectedNameInCell = dataSource[indexPath.row].yahooName with override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { if let cell = cellForRow(at: IndexPath) { selectedNameInCell = cell.yahooName // I assume you have such a property in the cell ; or maybe it is just cell.textLabel!.text if the name is the textLabel } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Unable to Dequeue Registered CollectionViewCells
Not sure that's the issue, but I usually register in viewDidLoad. Add some test here: override func awakeFromNib() { super.awakeFromNib() print(#function) And tell if you get the log.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to MacBook Pro 2019 long update time
Download was completed ? You are in the installation phase ? I advise to be very patient, if you are short on RAM, there me be a lot of swapping that slows everything a lot. I would wait a few more hours before doing anything.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
I wanted to avoid duplicates with an array. Yes, that's logical, but you should handle it when you populate the array. Or remove any duplicate in the array: var myArray = [/* Some items*/] var noReplicateArray = [] // with same types of items for item in myArray { if !noReplicateArray.contains(item) { noReplicateArray.append(item) } } You can also use reduce: noReplicateArray = myArray.reduce([]) {array, item in if array.contains(item) { return array } else { return array+[item] } } But the first appears to be much faster.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Is the result of Pegasus embedded in my phone or some different forensic software?
If you've really been hacked by Pegasus : bad news, your phone is compromised. Good news: you are among the 50000 most important people on earth😊… More seriously, a lot has been published on how to detect if infected (need to use Terminal). Note: I doubt the Pegasus you see here is the same. Would be really surprising for it to leave its full name here !
Replies
Boosts
Views
Activity
Jul ’21
Reply to Need Help Transfer Data From Button
My mistake, just change:     if let cell = tableView.cellForRow(at: IndexPath) {
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Fatal Exception UIPopoverPresentationController that sourceView is nil after setting sourceView
Maybe sourceRect of zero size causes the problem:    let popoverPresentationController = tableViewController.setUpPopoverPresentation( sourceView: borderLabel, sourceRect: CGRect(x: anchorX, y: anchorY, width: 0, height: 0)) Try and give non null width and height.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’21