I have the following code, which clicking on the button allows me to clone a repository that is on github.
import SwiftUI
import Git
struct File: View {
@State var pathUrl = "https://github.com/way-to-code/git-macOS.git"
@State var nameDir = "/Users/"
func cloneReport() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
let url: URL = URL(string: pathUrl)!
let report = GitRepository(from: url)
//report.delegate = progressTracker
do {
try report.clone(at: nameDir)
} catch let e {
print("Errors \(e).")
}
}
}
var body: some View {
Button(action: {
cloneReport()
}) {
Text("Clone").frame(width: 330)
}
}
}
struct File_Previews: PreviewProvider {
static var previews: some View {
File()
}
}
I am using the following framework that tells me if I want to implement the delegate of the framework protocol for track events, I have to do this:
let progressTracker = MyCustomObject()
let repository: GitRepository
repository.delegate = progressTracker
// implement RepositoryDelegate protocol in order to track the events
extension MyCustomObject: RepositoryDelegate {
func repository(_ repository: Repository, didProgressClone progress: String) {
}
}
I can't do extension of a class that doesn't exist gives me the following error: Cannot find type 'MyCustomObject' in scope
is it possible to extend a struct of type View?
Can you give me some advice?