Posts

Post marked as solved
1 Replies
337 Views
Hi, guys. Can someone confirm this problem so I submit the bug to Apple. When the Core Data Persistent Store is empty, the canvas preview crashes. To test it, you just need to create a new project with the Core Data option enabled. Then go to the Persistence.swift file created by the template, and remove the for in loop in the closure assigned to the preview property that creates 10 new items. The property will look like this: static var preview: PersistenceController = { let result = PersistenceController(inMemory: true)    return result }() Now, you will get an error when the system tries to fetch items [NSManagedObjectContext executeFetchRequest:error:]. You only need to add one single item for the error to disappear. It looks like a pretty bad bug, so I want to be sure it is not my computer. Thanks.
Posted
by macrojd.
Last updated
.
Post not yet marked as solved
3 Replies
2.1k Views
Hi, guys. I'm testing the new pop-up and pull-down buttons in iOS 15, but they do not show the pop-up menu when pressed (all the options in the Attributes Inspector panel are checked). They only work when I define the entire menu in code. My questions are: Is this because the feature was not implemented yet? If this is implemented later and we can define the menu in Interface Builder, how do you respond to a selection? In code, I can specify the action in the closure, but how do I do it if the menu is defined in Interface Builder? This is how I define the menu from code, just in case someone needs to know: import UIKit class ViewController: UIViewController {   @IBOutlet weak var myButton: UIButton!   override func viewDidLoad() {    super.viewDidLoad()         let optionsClosure = { (action: UIAction) in      print(action.title)    }    myButton.menu = UIMenu(children: [      UIAction(title: "Option 1", state: .on, handler: optionsClosure),      UIAction(title: "Option 2", handler: optionsClosure),      UIAction(title: "Option 3", handler: optionsClosure)    ])   } } Thanks JD
Posted
by macrojd.
Last updated
.
Post marked as solved
1 Replies
572 Views
Hi, guys. While trying to update the old code to the new AttributedString structure I realized that there are properties in UIKit that take a dictionary of NSAttributedString.Key values. For instance, the code below assigns a dictionary to the titleTextAttributes property of the UINavigationBarAppearance object. This property doesn't take an AttributeContainer value and I couldn't find any way to convert the container into a dictionary. Is there a way to do it or do we still have to use the old NSAttributedString.Key values in these cases? Thanks! class ViewController: UIViewController {    override func viewDidLoad() {     super.viewDidLoad()     let standard = UINavigationBarAppearance()     standard.titleTextAttributes = [.foregroundColor: UIColor.red]     navigationController?.navigationBar.standardAppearance = standard    } }
Posted
by macrojd.
Last updated
.
Post marked as solved
1 Replies
384 Views
Hi, guys. I want to put my apps on the cloud so I can develop them from any device, but after a while, the files are removed locally and I get errors. I need to store the files locally on every computer and get them to automatically synchronize with iCloud, but I can't find the option "Optimize Mac Storage" anymore. Also, if I deactivate that option are the files going to stay locally or there is anything else I have to do to make sure that happens? Thanks!
Posted
by macrojd.
Last updated
.
Post marked as solved
1 Replies
672 Views
Hi, guys. The use of @MainActor is confusing? Should I use it only to turn classes into main actors? What if one of my functions access the interface from a closure that could run on a different thread? How do I tell the system to access a label from the main thread? Should I mark the entire view controller class with the @MainActor? Is there anything similar to use with functions or statements or should I still use DispatchQueue.main? Thanks.
Posted
by macrojd.
Last updated
.
Post not yet marked as solved
2 Replies
550 Views
Hi, guys. How can I disable the popup windows that appear when you keep the mouse over an option in the Attributes Inspector panel?https://ibb.co/cwWRTFqI don't remember these windows poping up in previous versions. I think is a new "feature" but it becomes extremelly annoying after just a few minutes working on the storyboard. They do not only appear when you just leave the mouse over the option for a while but also when you are working with the option. For instance, try to change the tag value of an element. After you press the button three or four times, the help window appears and covers the field, not letting you see what you are doing. Probably the worse idea in the history of Xcode.Thanks
Posted
by macrojd.
Last updated
.
Post marked as solved
3 Replies
2.4k Views
Hi, guys. In iOS 12, the NSKeyedArchiver's initializer init(forWritingWith🙂 was deprecated. Xcode 10 recommends replacing it with the new initializer init(requiringSecureCoding:). The problem is that this initializer only sets the value of the requiresSecureCoding property of the NSCoder object, but it doesn't set the NSMutableData object that will contain the encoded data. The following is the original code propose by Apple to encode the metadata of a CKRecord (CloudKit record):let data = NSMutableData()let coder = NSKeyedArchiver.init(forWritingWith: data)coder.requiresSecureCoding = truerecord.encodeSystemFields(with: coder)coder.finishEncoding()The encodeSystemFields method of the CKRecord class requires an NSKeyedArchiver object (an NSCoder subclass) and the encoded data is stored in the NSMutableData object associated with this object. If I replace the init(forWritingWith🙂 initializer by the init(requiringSecureCoding:) initializer, I get an NSKeyedArchiver object, but this object is not associated with any NSMutableData object and therefore I don't get the record's metadata. I'm not sure how to complete the code to get the data produced by the NSKeyedArchiver object into an NSMutableData object.
Posted
by macrojd.
Last updated
.
Post not yet marked as solved
1 Replies
721 Views
Hi, guys. I've found a critical bug in Navigation Bars on Xcode 9.1 and Xcode 9.2 Beta, but I need someone to test it to know if it is a bug or something is wrong on my computer. The problem is that you can't access the Navigation Item of a Navigation Bar from Interface Builder when the View Controller is the Detail View of a Split View Controller. To make it easy for you, here are the steps to reproduce the bug:- Open Xcode 9.1 or 9.2 Beta- Create a new project with the Master-Detail template- Try to add a Bar Button Item to the Navigation Bar of the Detail view (the Detail view is embedded in a Navigation Controller)If you can't add the button, or click on the bar to change the title, you have the same problem I have. If you erase the Detail View Controller segue, the Navigation Bar becomes available, which shows that the problem is when the Navigation Controller is the Detail view of a Split View Controller.This is a critical bug because it makes impossible to create applications with a Split View Controller. But it only happens in Xcode 9.1 or Beta. I installed Xcode 9.0 and now the problem is solved. It is unreal because I can't believe that nobody at Apple noticed this problem, so I need someone's confirmation before filing a bug.Thanks
Posted
by macrojd.
Last updated
.