Post not yet marked as solved
One of my clients agreed to use SwiftUI for some views but they require a fixed font size.
Setting the Dynamic Type for a custom view works fine, but controls like Menu, Picker or even the confirmation dialog view, ignore the given Dynamic Type.
Any suggestion? (beside not using SwiftUI yet)
Thank you
Post not yet marked as solved
I'm making a test with SwiftUI and my app (that uses coredata) and I'm having some problems.I managed to make to work NSFetchedResultsController and it works nicely. The problem occurs when I made searches (changing the predicate) and the List must update the changes. It seems that not only the visible "rows" are compared between the old and new fetchedObjets (as before with the old UITableView), but the entire list and that is extremely slow.The logs that I'm seeing with SQLDebug level 4 are showing me that all objets are being loaded in batches of 20 objets (fetchBatchSize = 20).This is my code for the List View:struct OrderListView: View {
@ObservedObject var searchOrderFilter: SearchOrderFilter
var body: some View {
List {
SearchView(searchText: $searchOrderFilter.searchText, selectedOption: $searchOrderFilter.selectedOptionIndex, placeholder: "Search", options: ["Address", "Work", "Client", "Phone", "PO"])
ForEach(searchOrderFilter.fetchedResultsController.fetchedObjects!, id: \.objectID) { (order) in
OrderCellView(order: order)
}
}
.navigationBarItems(trailing: HStack(alignment: .center, spacing: 20.0) {
Button(action: {}, label: { Text("Select") })
Button(action: {}, label: { Text("Filter") })
Button(action: {}, label: { Text("+") })
})
.navigationBarBackButtonHidden(false)
.listStyle(DefaultListStyle())
}
}And this is my current (testing) SearchOrderFilter class:final class SearchOrderFilter: NSObject, ObservableObject, NSFetchedResultsControllerDelegate {
public let objectWillChange = PassthroughSubject<SearchOrderFilter, Never>()
private var filterType: Order.FilterType
@Published var searchText: String = "" {
didSet {
if oldValue != searchText {
fetchOrders()
}
}
}
@Published var selectedOptionIndex: Int = 0 {
didSet {
if oldValue != selectedOptionIndex {
fetchOrders()
}
}
}
public func setFilter(filterType: Order.FilterType) -> SearchOrderFilter {
if self.filterType != filterType {
self.filterType = filterType
self.searchText = ""
self.selectedOptionIndex = 0
fetchOrders()
}
return self
}
init(filterType: Order.FilterType) {
self.filterType = filterType
super.init()
updateCounterForCommonFilter()
}
public var fetchedResultsController: NSFetchedResultsController<Order> = NSFetchedResultsController(fetchRequest: Order.filteredFetchRequest(filterType: .none), managedObjectContext: CoreDataCache.sharedInstance.persistentContainer.viewContext, sectionNameKeyPathme:
private func fetchOrders() {
let filterSecondaryType = Order.FilterSecondaryType(rawValue: selectedOptionIndex) ?? Order.FilterSecondaryType.none
let fetchRequest = Order.filteredFetchRequest(filterType: self.filterType, filterBy: filterSecondaryType, se
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: CoreDataCache.sharedInstance.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
fetchedResultsController.delegate = self
//_fetchedResultsController.fetchRequest.predicate = fetchRequest.predicate
do {
print("perform fetch")
try fetchedResultsController.performFetch()
} catch {
objectWillChange.send(self)
//_fetchedResultsController = nil
}
}
// MARK: NSFetchedResultsControllerDelegate
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
print("controller will change content")
objectWillChange.send(self)
}
}Forgive me if the last code doesn't look right, I had some problems copying it and it's my test class (where I'm trying many different approches).I also tried using the @FetchRequest but I couldn't find how I can change the predicate when I'm doing new searches.If someone has a tip or any comment, I'd appreciate it.Thank you
Post not yet marked as solved
Hi everyone,
I'm trying to add a tap gesture to a Map with no interactions enabled (static), but it seems that the gesture is intercepted (and ignored) by the Map view.
Is this a bug or there is a way to do it?
Thank you,
Post not yet marked as solved
I always have problems when trying to animate rows. At this moment I'm trying to add content to a row when the user taps over the cell (to show some details).
I'm using withAnimation and a @state variable to control when the extra content appears.
The problem is that the animation it's so weird. It's like the cell resize first without animation, then the current content starts moving from the center while the new content appears.
What I want is that the current content stays on top of the row while the added content appears from the bottom, making the cell higher.
Is there any way to really control transitions and animations when using List ?
Post not yet marked as solved
Anyone else is having the same problem?
I just upgraded to the last Beta and I started seeing the problem in the simulator, but it's also happening on my device.
Should I wait or downgrade my device?
Post not yet marked as solved
I'm testing the new concurrency (actor, await, group, etc) and I'm having a weird (for me) problem.
I have a method that executes 9 concurrent process using withThrowingTaskGroup. Each process starts fetching data from coredata, each in their own context.
I start the execution tapping a button.
The problem is that sometimes the execution get paused, usually in a very similar place (in an await context.perform{}). The code inside the perform executes well, but it's like the await doesn't return control to the next line of code.
The curious thing is that if I tap the button again, the old paused process continues and finishes, while the second process runs its own execution.
Is there any way to track what is happening?
Post not yet marked as solved
Reading the CKQuery documentation, I found this example:
[NSPredicate predicateWithFormat:@"ANY favoriteColors BEGINSWITH %@", matchString]
If favoriteColors is a String List, that means that I can search for the beginning of each value in the string list, however if I tried this, the app crashes.
Terminating app due to uncaught exception 'CKException', reason: 'Invalid predicate: ANY nameSearch BEGINSWITH "Do"
In my test, nameSearch is a String List.
I don't know if I'm understand the documentation wrong and favoriteColors is not a string list, but then why they are using ANY?
Post not yet marked as solved
I'm doing some test with the new zone sharing feature, but when I fetch the shared zones, I'm only getting the zoneID in return.
How can I get the (current) user permissions in each of his shared zones that he has accepted?
If I don't have the CKShare ID, I can't request for it.
I have an app that uses CloudKit to share records between multiple users and coredata as a local read-write cache.I'm interested in the new automatic coredata+cloudkit integration, but I'm not sure how or if this will support sharing records with other cloudkit users.I haven't test iOS 13 beta, yet, but I'm planning to do it in the next weeks.Does someone have any knowledge about this? My bet is that is not supported, but I want to be sure.Thank you
Post not yet marked as solved
I'm doing some test with the new async/await methods in CKDatabase and I found this one:
configuredWith(...)
How I'm supposed to use it? I haven't found any example.
Post not yet marked as solved
Hi,I'm trying to understand what does it mean that NSManagedObject is an ObservableObject, but I have not being able to find out.My database is synchronize in the background and I want to know when an attribute of an NSManagedObject changes. I could still use the NotificationCenter, but I wonder what can I do with an ObservableObject.Any idea ? Any tips ?I haven't found any useful information anywhere.Thank you
Post not yet marked as solved
Testing NavigationView, if I set leading navigationBarItems, the back button doesn't appear, even setting the navigationBarBackButtonHidden to false.The back button only appears when I do not set any leading item.I'm not sure if is a bug or I'm doing something wrong.Any suggestion ?Thank you,