I have a question about code in the ShapeEdit sample from Apple.I their code, as shown below, why did they use FileManager's copyItem method instead of its setUbiquitous method? Didn't the documentation say explicitly to use setUbiquitous method? NSFileCoordinator().coordinate(with: [readIntent, writeIntent], queue: self.coordinationQueue) { error in
if error != nil {
return
}
do {
try fileManager.copyItem(at: readIntent.url, to: writeIntent.url)
try (writeIntent.url as NSURL).setResourceValue(true, forKey: URLResourceKey.hasHiddenExtensionKey)
OperationQueue.main.addOperation {
self.openDocumentAtURL(writeIntent.url)
}
}
catch {
fatalError("Unexpected error during trivial file operations: \(error)")
}
}
Post
Replies
Boosts
Views
Activity
Anyone have any recommendations on how to resize a screen video of an iPhone from 750x1334 to 1080x1920 as required by App Store Connect? Or any alternative solutions?
How can my app get the dimensions of the screen?
I clicked the delete button to an App ID in my developer account and I got a message saying "All certificates associated with the App ID will be deleted and any provisioning profiles associated with this App ID will be invalidated." Why would the entire provisioning profile be invalidated? What about the other App IDs in that provisioning profile? Does that mean I wouldn't be able to use the provisioning profile for those other App IDs at all?
Why am I getting an error message when I try to validate an archive that says, "No accounts with iTunes Connect access have been found for the team. iTunes Connect access is required for App Store distribution."?I have never gotten this error message before. What should I do?
How do I get the microseconds of an object of type Date? I'm open to any suggestions. I'm not able to set the dateFormat property of DateFormatter to be able to show microseconds.
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)
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?
Anyone know where I can get a list of all the UserDefaults keys? I can't find it in documentation.
Is there an inherent way for the text field to be able to automatically show the phone number using a format of (###) ###-####, or is that something I have to code myself?
I included the Tests and UITests schemas when I created my Xcode project, but now I want to remove them. Even if I delete those groups, I still get build errors on the files and the files still show in the editor. How do I remove those files from my project for good?
If I've already set contraints using code in iOS, how do I change the constraits?
What are guidelines for numbering the build number? Should it just start with 0 and increment by one each time I archive a project for distribution?
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?
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?