Post

Replies

Boosts

Views

Created

Making sure remote data is loaded before setting Collection View delegate and datasource
Hi, I wish to remotely load some data before I initialise the collection view. I read somewhere one way to do this is to only set the delegate and datasource after I loaded the data. However I'm setting the error "UICollectionView.delegate must be used from main thread only" next to the line self.myCollectionView.delegate = self I suppose this is not the best way to do this. What is the recommended way? Cheers Richard
1
0
1.1k
Apr ’22
Getting the following error when trying to fetch a remote image.
Hi, I'm writing code to get a remote image via URL and I get the following error each time. I converted the URL to https as recommended. This is the error I get. URL is Optional(https://img.recipepuppy.com/627470.jpg) 2022-03-29 16:27:41.892870+1100 QantasTest[13489:314159] ATS failed system trust 2022-03-29 16:27:41.892949+1100 QantasTest[13489:314159] Connection 3: system TLS Trust evaluation failed(-9802) 2022-03-29 16:27:41.893119+1100 QantasTest[13489:314159] Connection 3: TLS Trust encountered error 3:-9802 2022-03-29 16:27:41.893212+1100 QantasTest[13489:314159] Connection 3: encountered error(3:-9802) 2022-03-29 16:27:41.894548+1100 QantasTest[13489:314159] Task <526F7B9B-ADC8-4D14-8EA6-DEAD629E7C5A>.<0> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9802]) 2022-03-29 16:27:41.894666+1100 QantasTest[13489:314182] NSURLConnection finished with error - code -1200 The code I use is: print("URL is \(String(describing: self.thumbNailUrl))") DispatchQueue.global().async { [weak self] in if let data = try? Data(contentsOf: self!.thumbNailUrl!) {             if let image = UIImage(data: data) {                                 DispatchQueue.main.async {                                     self?.imageView.image = image                                 }                             }                         }               } Any suggestions? Cheers Richard
2
0
1.7k
Mar ’22
SwiftUI. Navigation toolbar not working after dismissing modal
Hi, Anyone encountered this? I bring up a modal sheet using my add button. Then I dismiss it by swiping down. Immediately after that, the button is unresponsive and I cannot bring up the modal sheet again. However, if I scroll the list, the button is functional again. I can include a video of what I see if you like. Snippet of my code below. struct TaskToDoView: View {     @Environment(\.managedObjectContext) private var viewContext     @FetchRequest(         sortDescriptors: [NSSortDescriptor(keyPath: \SimpleRecord.title, ascending: true)],         animation: .default)     private var items: FetchedResults<SimpleRecord>     @State private var isModal = false          var body: some View {         NavigationView {             List {                 ForEach(items) { item in                     NavigationLink(destination: ToDoModelView()) {                         Text("Item at \(item.title!)")                     }                                      }                 .onDelete(perform: deleteItems)             }             .toolbar {                 HStack {                     #if os(iOS)                     EditButton()                     #endif                      Button(action: addItem) {                         Label("Add Item", systemImage: "plus")                     }                     .sheet(isPresented: $isModal,                             onDismiss: dismissToDoModelView,                             content: {                         ToDoModelView()                     })                 }             }         }     }     private func dismissToDoModelView() {         print("Modal Dismissed")         print("Modal is \(self.isModal)")     }     private func addItem() {         self.isModal.toggle()     } .... }
5
1
2.1k
Jul ’21
Is there an easy way to convert a MLX format model to Core ML
Hi, I'd like to use a MLX model already in the MLX Community in my App. I understand I first need to convert it to Core ML format. Is there an easy way to do that considering MLX is an Apple project? It would be good if it was easier then I'd be more motivated to use MLX to train my models. Thanks Richard
Replies
1
Boosts
1
Views
1.9k
Activity
Jun ’24
Making sure remote data is loaded before setting Collection View delegate and datasource
Hi, I wish to remotely load some data before I initialise the collection view. I read somewhere one way to do this is to only set the delegate and datasource after I loaded the data. However I'm setting the error "UICollectionView.delegate must be used from main thread only" next to the line self.myCollectionView.delegate = self I suppose this is not the best way to do this. What is the recommended way? Cheers Richard
Replies
1
Boosts
0
Views
1.1k
Activity
Apr ’22
Getting the following error when trying to fetch a remote image.
Hi, I'm writing code to get a remote image via URL and I get the following error each time. I converted the URL to https as recommended. This is the error I get. URL is Optional(https://img.recipepuppy.com/627470.jpg) 2022-03-29 16:27:41.892870+1100 QantasTest[13489:314159] ATS failed system trust 2022-03-29 16:27:41.892949+1100 QantasTest[13489:314159] Connection 3: system TLS Trust evaluation failed(-9802) 2022-03-29 16:27:41.893119+1100 QantasTest[13489:314159] Connection 3: TLS Trust encountered error 3:-9802 2022-03-29 16:27:41.893212+1100 QantasTest[13489:314159] Connection 3: encountered error(3:-9802) 2022-03-29 16:27:41.894548+1100 QantasTest[13489:314159] Task &lt;526F7B9B-ADC8-4D14-8EA6-DEAD629E7C5A&gt;.&lt;0&gt; HTTP load failed, 0/0 bytes (error code: -1200 [3:-9802]) 2022-03-29 16:27:41.894666+1100 QantasTest[13489:314182] NSURLConnection finished with error - code -1200 The code I use is: print("URL is \(String(describing: self.thumbNailUrl))") DispatchQueue.global().async { [weak self] in if let data = try? Data(contentsOf: self!.thumbNailUrl!) {             if let image = UIImage(data: data) {                                 DispatchQueue.main.async {                                     self?.imageView.image = image                                 }                             }                         }               } Any suggestions? Cheers Richard
Replies
2
Boosts
0
Views
1.7k
Activity
Mar ’22
SwiftUI. Navigation toolbar not working after dismissing modal
Hi, Anyone encountered this? I bring up a modal sheet using my add button. Then I dismiss it by swiping down. Immediately after that, the button is unresponsive and I cannot bring up the modal sheet again. However, if I scroll the list, the button is functional again. I can include a video of what I see if you like. Snippet of my code below. struct TaskToDoView: View {     @Environment(\.managedObjectContext) private var viewContext     @FetchRequest(         sortDescriptors: [NSSortDescriptor(keyPath: \SimpleRecord.title, ascending: true)],         animation: .default)     private var items: FetchedResults<SimpleRecord>     @State private var isModal = false          var body: some View {         NavigationView {             List {                 ForEach(items) { item in                     NavigationLink(destination: ToDoModelView()) {                         Text("Item at \(item.title!)")                     }                                      }                 .onDelete(perform: deleteItems)             }             .toolbar {                 HStack {                     #if os(iOS)                     EditButton()                     #endif                      Button(action: addItem) {                         Label("Add Item", systemImage: "plus")                     }                     .sheet(isPresented: $isModal,                             onDismiss: dismissToDoModelView,                             content: {                         ToDoModelView()                     })                 }             }         }     }     private func dismissToDoModelView() {         print("Modal Dismissed")         print("Modal is \(self.isModal)")     }     private func addItem() {         self.isModal.toggle()     } .... }
Replies
5
Boosts
1
Views
2.1k
Activity
Jul ’21