Posts

Post not yet marked as solved
1 Replies
660 Views
There is a new Relationship macro in Xcode Beta 6. The macro includes two new arguments: minimumModelCount and maximumModelCount. I wonder if anyone knows what these values are for and if there is another change under the hood. Relationship( _ options: PropertyOptions..., deleteRule: Schema.Relationship.DeleteRule = .nullify, minimumModelCount: Int? = 0, maximumModelCount: Int? = 0, originalName: String? = nil, inverse: AnyKeyPath? = nil, hashModifier: String? = nil )
Posted
by macrojd.
Last updated
.
Post not yet marked as solved
1 Replies
1.3k Views
Hi, guys. In Xcode Beta 4, the PhotosPicker view doesn't modify the state property when all the items are deselected. This seems to be a bug, but I don't know how to file a bug for a beta API. This code generates a list with the selected pictures. If you select a picture and then deselect it, the item is not removed from the list. import SwiftUI import PhotosUI struct ContentView: View {    @State private var selected: [PhotosPickerItem] = []    var body: some View {       NavigationStack {          List(selected, id: \.itemIdentifier) { item in             Text(item.itemIdentifier ?? "")          }          .toolbar {             ToolbarItem(placement: .navigationBarTrailing) {                PhotosPicker(selection: $selected, matching: .images, photoLibrary: .shared()) { Text("Select Photos") }             }          }       }    } }
Posted
by macrojd.
Last updated
.
Post not yet marked as solved
2 Replies
1.1k Views
Hi. The binding in a ForEach or List view doesn't work anymore when using the @Observable macro to create the observable object. For example, the following are the modifications I introduced to the Apple's example called "Migrating from the Observable Object Protocol to the Observable Macro" https://developer.apple.com/documentation/swiftui/migrating-from-the-observable-object-protocol-to-the-observable-macro struct LibraryView: View { @Environment(Library.self) private var library var body: some View { List($library.books) { $book in BookView(book: book) } } } All I did was to add the $ to turn the reference to library.books into a binding but I got the error "Cannot find '$library' in scope" Is this a bug or the procedure to use binding in lists changed? Thanks
Posted
by macrojd.
Last updated
.
Post marked as solved
1 Replies
1.3k 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
4.5k 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
1.2k 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
813 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
1.2k 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
1.1k 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
.