How do I sign in to Azure devops accounts from xcode preferences. The account for Azure doesn't show up. The code is already hosted on Azure Devops and I was working on an already made project and the repo is already in the azure devops account. The previous account was obselete and now I need to login to my own account to push the changes. Whenever I am trying to push and commit the changes I get an error:
remote: You are not authorized to access this collection. (-20)
Post
Replies
Boosts
Views
Activity
I have implemented a PDFView in the app but it is unable to show the pdf downloaded from the web service.
If I add a bundle resource in the project it loads it fine. But the one from the API is not loaded.
I have added the code below to check further.
struct UploadQuotationView: View {
let frId: String = "FR-DEMO-062021-00116"
@State var downloadURL = URL(string: "https://www.apple.com")
// @State var fileURL = Bundle.main.url(forResource: "c4611_sample_explain", withExtension: "pdf")
@State var docSheet = false
@State var pdfView = PDFKitRepresentedView(Data())
@State var data = Data()
var body: some View {
VStack{
Button("View PDF"){
//downloadFile()
downloadAndView(fileName: "Quotation\(frId)")
//fileURL = Bundle.main.url(forResource: "fileSample", withExtension: "pdf")
}
.onAppear(){
// downloadAndView(fileName: "Quotation\(frId)")
}
.padding()
PDFKitRepresentedView(data)
.cornerRadius(10)
.padding()
.shadow(radius: 10)
Button("document picker"){
docSheet.toggle()
}
.sheet(isPresented: $docSheet) {
DocumentPickerView()
}
.padding()
}
}
func downloadAndView(fileName:String) {
guard let url = URL(string: "\(CommonStrings().apiURL)faultreport/quotation/\(frId)") else {return}
var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "GET"
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.setValue(UserDefaults.standard.string(forKey: "token"), forHTTPHeaderField: "Authorization")
urlRequest.setValue(UserDefaults.standard.string(forKey: "role"), forHTTPHeaderField: "role")
urlRequest.setValue( UserDefaults.standard.string(forKey: "workspace"), forHTTPHeaderField: "workspace")
print(urlRequest)
let dataTask = URLSession.shared.dataTask(with: urlRequest) { (data, response, error) in
if let error = error {
print("Request error: ", error)
return
}
guard let response = response as? HTTPURLResponse else {
print("response error: \(String(describing: error))")
return
}
if response.statusCode == 200 {
if let pdfData = data {
print("success")
//pdfView = PDFKitRepresentedView(pdfData)
self.data = pdfData
}
}else{
print("Error: \(response.statusCode). There was an error")
}
}
dataTask.resume()
}
}
struct PDFKitRepresentedView: UIViewRepresentable {
let pdfView = PDFView()
let data: Data
init(_ data: Data) {
self.data = data
}
func makeUIView(context: UIViewRepresentableContext<PDFKitRepresentedView>) -> PDFKitRepresentedView.UIViewType {
pdfView.document = PDFDocument(data: data)
pdfView.displayMode = .singlePage
pdfView.displayDirection = .horizontal
return pdfView
}
func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<PDFKitRepresentedView>) {
pdfView.document = PDFDocument(data: data)
}
}
There are some variables that you can modify as per your liking like the api URL and similar.
I have added the screenshot that shows the data is loaded in the "data" variable when the API request is success. Please check the screenshot.
I am working on a SwiftUI application. I am using a list which displays the response from the server. Once the user clicks on the list item, it opens up a new view which loads another data from the server on some textviews and buttons. However, when the data fully loads, the back button disables. Please refer to the attached video. [https://1drv.ms/v/s!Au1n19s_ZcghxgssOZFa_6vcUxBO?e=9xZUGh]
I have created a custom view which contains a textview, a textfield and a picker with three items.
Now this is added by iterating an array using a foreach loop. These can be more than one based on the response from the server. Now I wish to get the data back from the textfield and the textfield. I tried to use Binding in the forEach loop but it is now receiving any update done in these views.
I have a list of remarks which I receive from an API call. I have created a loop to create TEXT from the remarks but the texts do not appear in the application. Please check the code.
I have also checked the debugger and it shows a the string present there but it doesn't create the text.
VStack{
Text("Remarks")
.padding(.horizontal, 15)
.font(.title2)
if(currentFrResponse.remarks != nil){
List(currentFrResponse.remarks!, id:\.self){ currentRemark in
VStack{
Text(currentRemark)
.bold()
.padding()
}.padding()
}
}
}
Let me know if you need any more details