I'm kind of new to Ios development and still figuring out Xcode.
I have downloaded Xcode 12 beta 3 and I am using SwiftUI.
I was using Xcode 11 and when I wrote print("something") everything went well.
after upgrading to 12 beta 3 no print statement is working for me and errors are not shown as well.
I am trying to understand if it something I did wrong in Xcode settings or maybe a bug.
Any help or suggestion will do.
btw, the network request doesn't get to the server. I believe it fails before. the server is working properly. Maybe this info can assist someone.
Thanks a lot in advance!
code sample:
import Foundation
protocol TodosNetworkServiceProtocol {
func fetchTodos(includingCompleted: Bool) -> [Todo]
func update(todo: Todo)
func add(todo: Todo)
func toggleIsCompleted(for todo: Todo)
}
// final class means it cant be inharited
final class TodosNetworkService: TodosNetworkServiceProtocol {
func fetchTodos(includingCompleted: Bool) -> [Todo] {
guard let todosUrl = URL(string: "http://localhost:5000/todos") else { return [] }
URLSession.shared.dataTask(with: todosUrl) { (data, response, error) in
// Here it gets into the if but print nothing.
if error != nil { print(error) }
guard let data = data else { return }
do {
let response = try JSONDecoder().decode([Todo].self, from: data)
} catch let err {
print(err)
return
}
}.resume()
return []
}
func update(todo: Todo) {
print("updating todo")
}
func add(todo: Todo) {
print("adding todo")
}
func toggleIsCompleted(for todo: Todo) {
print("toggeling todo")
}
}