Post

Replies

Boosts

Views

Activity

Reply to How do you use the new "Document Tabs" feature?
Ctrl + Tab is used for passing between "window tab bar" tabs. If this feature is not present, open it via "View->Show window Tab Bar". Besides, you can use "document tabs" which seems a new & nice feature of Xcode. You can see their default shortcuts via "Navigate -> Show Previous Tab" or "Navigate -> Show Next Tab" or find them on the "Key Binding" tab under "Xcode ->Preferences window" There are many default shortcuts and I do not want them to change. I am using Turkish keyboard and default shortcuts are not useful. In short, I generally choose Turkish (/your native language) letters for shortcuts. No conflict, no headache. I suggest similar use.
Sep ’20
Reply to List with Bindings from ObservedObject
Another way of doing it. import SwiftUI import Combine struct ContentView: View {     @ObservedObject var api = TodoAPI()     var body: some View {         VStack {             List{                 Button(action: {                     api.fetchTodos()                 }, label: {                     Text("Get todos")                 })                 ForEach(0..<api.todos.count) { idx in                     HStack {                         Image(systemName: (api.todos[idx].isDone ? "checkmark.circle.fill" : "checkmark.circle"))                         ToDoRowView(todo: $api.todos[idx])                     }                 }             }         }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } struct ToDoRowView: View {     @Binding var todo:Todo     var body: some View {         HStack {             Text(todo.title)                 .font(.title3)                 .padding()             Spacer()             Button(action: {                 self.todo.isDone.toggle()             }, label: {                 Text("DONE").padding(5).background(Color( colorLiteral(red: 0.721568644, green: 0.8862745166, blue: 0.5921568871, alpha: 1)))             })         }     } } struct Todo: Identifiable {     var id = UUID()     var title: String     var isDone = false } class TodoAPI: ObservableObject {     @Published var todos:[Todo] = []     init() {         fetchTodos()     }     //fetch data from API     func fetchTodos(){         todos = [             Todo(title: "Feed the dog"),             Todo(title: "Drink 5 glass of water"),             Todo(title: "Do the homework"),             Todo(title: "Call grandma"),             Todo(title: "Task - \(Int.random(in: 1...100))")         ]     } }
Jun ’21
Reply to After upgrade Xcode 13,run playground occur a error。
Messages are pretty clear but I do not know why they happen or show in debug area. Adding following lines at the first or second line of my playground project page just works for me. I hope it helps you too. import PlaygroundSupport; defer{ PlaygroundPage.current.finishExecution() } My guess about the cause of this situation is that compiler keeps doing things after your code finish executing, such as it walks over libraries, tries to optimize things in the background, etc... I think in practice we never use conflicting libraries in any real projects at the same time, so that it only occurs at playground. Regards,
Jan ’22
Reply to AsyncImage - Cancelled Loading before View is Visible
I have the same issue with iOS 15.2. Actually the reason is clear and iOS behavior is acceptable. I am trying to fetch 20 images at the same time... On the other hand I have to overcome this issue... So my quick workaround is like the following; I hope it works for your scenario. I also try to improve it(, if I have time). AsyncImage(url: url) { phase in switch phase { case .success(let image): image .resizable() .scaledToFill() case .failure: //Call the AsynchImage 2nd time - when there is a failure. (I think you can also check NSURLErrorCancelled = -999) AsyncImage(url: url) { phase in if let image = phase.image { image .resizable() .scaledToFill() } else{ Image(systemName: "xmark.octagon") } } //... } }
Jan ’22