Post

Replies

Boosts

Views

Activity

EKEventStoreChanged
I'm trying to enable my app to receive a notification each time the event store changes.The documentation for EKEventStore at https://developer.apple.com/reference/eventkit/ekeventstore shows the following:static let EKEventStoreChanged: NSNotification.NameWhat does that mean? How do I use that information?
2
0
1.2k
Feb ’22
current time
I used the Date class such as "currentTime = Date()", but I get a date that is off by 5 hours exactly. How do I get the current time? Is there a time zone setting I have to set?
18
0
5.6k
Aug ’23
sort array of dictionaries
How do I sort an array of dictionary objects based on the value of the dictionary? I understand I should use the sorted method of the array, but I don't understand the notation that uses $0.1 and $0.0. Where is the documentation on that?
9
0
6.6k
Jan ’22
app logging
Does Cocoa Touch provide a convenient way for apps to perform logging? Perhaps something similar to the print() command except it is kept after the app is installed?
Topic: UI Frameworks SubTopic: UIKit Tags:
6
0
1.7k
Jan ’22
Why are table view cells not showing in table view?
I am using more than one table view cell class on a table view. I have registered the reuse identifiers and the xibs. For some reason the cells are not showing. What should I check. I'm stumped.Here is my code:import UIKit class DetailTableViewController: UITableViewController { let items = [0, 1] override func viewDidLoad() { super.viewDidLoad() tableView.register(DueDateSwitchTableViewCell.self, forCellReuseIdentifier: "DueDateSwitchTableViewCell") let xibDueDateSwitchTableViewCell = UINib(nibName: "DueDateSwitchTableViewCell", bundle: Bundle.main) tableView.register(xibDueDateSwitchTableViewCell, forCellReuseIdentifier: "DueDateSwitchTableViewCell") tableView.register(DueDatePickerTableViewCell.self, forCellReuseIdentifier: "DueDatePickerTableViewCell") let xibDueDatePickerTableViewCell = UINib(nibName: "DueDatePickerTableViewCell", bundle: Bundle.main) tableView.register(xibDueDatePickerTableViewCell, forCellReuseIdentifier: "DueDatePickerTableViewCell") } override func numberOfSections(in tableView: UITableView) -> Int { return 1 } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return items.count } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { print("tableView(_:cellForRowAt:)", "indexPath.row=", indexPath.row) let cell = UITableViewCell() switch indexPath.row { case 0: print("\tcase 0") let cell = tableView.dequeueReusableCell(withIdentifier: "DueDateSwitchTableViewCell", for: indexPath) as! DueDateSwitchTableViewCell cell.backgroundColor = UIColor.yellow case 1: print("\tcase 1") let cell = tableView.dequeueReusableCell(withIdentifier: "DueDatePickerTableViewCell", for: indexPath) as! DueDatePickerTableViewCell cell.datePicker.date = Date() default: break } return cell } }The cells show the numbers when I use this code in tableView(_:cellForRowAt:) before the line that says "return cell": cell.textLabel!.text = String(items[indexPath.section].hashValue)
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
13k
Jul ’21
How do I cause a timer to fire while the app is in the background?
When I write code for a timer like below, the timer doesn't fire if the device is locked. How do I cause the code in the timer closure to run when the app is in the background? Are there any other ways to cause specific code to run at a certain time when the app is in the background? func setTimer(alarm: UTIAlarm) { let timer = Timer(fire: alarm.date!, interval: 0, repeats: false) { (timer: Timer) in print("timer fire \(self.dateFormatter.string(from: alarm.date!))") do { try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation) } catch { print("Failed to setActive AVAudioSession from timer closure.") print(error.localizedDescription) } let predicate = MPMediaPropertyPredicate(value: alarm.mediaItem!.title, forProperty: MPMediaItemPropertyTitle) let query = MPMediaQuery() query.addFilterPredicate(predicate) self.playerController!.setQueue(with: query) self.playerController!.play() } runLoop.add(timer, forMode: .default) timers.append(timer) }
Topic: UI Frameworks SubTopic: UIKit Tags:
7
0
3.7k
Oct ’21
Environment variables
In Info.plist of my Xcode project, I see for instance "Executable file" is set to "$(EXECUTABLE_NAME)". I believe that "$(EXECUTABLE_NAME)" is called an environment variable. What I'd like to know is where is that environment variable set. I'd like to see where all the environment variables are set so I can use those values.
6
0
12k
Sep ’21