Post

Replies

Boosts

Views

Activity

Learning to use User Defined Runtime Attributes
Hi, I'm new to iOS development. I'm trying to set User Defined Runtime Attributes to a button and getting the Key path as "music.key" as String. I then try to get the value using the code below in the ViewCOntroller. print(sender.value(forKeyPath: "music.key")!) I get the error 2020-10-06 12:05:11.519925+1100 Xylophone[81797:29787109] Failed to set (music.key) user defined inspected property on (UIButton): [<UIButton 0x7fe1ffc0c410> valueForUndefinedKey:]: this class is not key value coding-compliant for the key music. What am I doing wrong? Is there a page on how to properly use User Defined Runtime Attributes? Much Appreciated. Thanks
1
0
2.5k
Oct ’20
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
1.9k
Jul ’21
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
2
0
1.4k
Mar ’22
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
957
Apr ’22