Post

Replies

Boosts

Views

Activity

fileImporter modifier: Problem to get a positive App Store Connect Feedback
I have written an App with a fileIpmorter modifier. I used TestFlight to pass it to friend for a test. The App works fine until my friend uses the fileImporter function: He can select the file to import (simple csv file), the fileImporter closes without having read out the csv file! I was able to analyze that the do-catch-block within the fileImporter modifier throws an error at the mac of my friend. The App behaves totally different to my Mac: On my Mac it works perfectly: the csv file is read out and the data can be used within the APP. Why does it behave like this? Why does this happen to the mac of my friend but not on mine? More strange: The Apple team is not able to even use the csv-file I passed them in the App Store Connect process: They are not able to select the file in the downloads folder. All three used MAC´s with three different behaviors? - How comes?
0
0
65
1d
No Observable Object of type...found
I am learning SwiftUI. Error: SwiftUI/Environment+Objects.swift:32: Fatal error: No Observable object of type ViewModel found. A View.environmentObject(_:) for ViewModel may be missing as an ancestor of this view. I do not get the point why this happens. The error is shown in the line : "renderer.render {... import SwiftData import SwiftUI @Observable class ViewModel { var groupNumber: String = "Gruppe" var sumOfHours: Int = 0 var personsToPrint: [Person]? = nil @MainActor func pdfReport(person: [Person]) { if personsToPrint != nil { for person in personsToPrint! { let renderer = ImageRenderer(content: PersonDetailView(person: person)) let url = URL.documentsDirectory.appending(path: "\(person.lastname) \(person.firstname).pdf") print(person.lastname, person.firstname) renderer.render { size, context in var box = CGRect(x: 0, y: 0, width: size.width, height: size.height) guard let pdf = CGContext(url as CFURL, mediaBox: &box, nil) else { return } pdf.beginPDFPage(nil) context(pdf) pdf.endPDFPage() pdf.closePDF() let data = try! Data(contentsOf: url) //pdf muss erst in Daten umgewandelt werden. do { try data.write(to: url) print("Daten wurden hier gespeichert: \(url)") } catch { print("PDF could not be saved!") } } } } } }
1
0
838
Dec ’23
Update App Content Data
Hello, I would like to create an app, which helps people to learn a language. The app content I would like to change using text files. As beginner in SWIFT programming I would need a hint how to pass new content in my app. I thought to use text files, placed on a web site. If the text file is updated, the app should get the newest content automatically. Does this make sense? What would be the best solution to achieve this target? Is there any helpful video in the "Developer" app or somewhere else? Thanks a lot.
2
0
680
Sep ’21
Read a text file with swift
There are several posts already. But none helps me in my task. Sometimes error message appears: "The file "Text.strings" couldn't be opened using text encoding Unicode (UTF-8)." Sometimes the text is shown in strange format. Why? import Foundation func printLine() -> String {     let filename = "Text"     var text: String     var myCounter: Int          guard let file = Bundle.main.url(forResource: filename, withExtension: "strings")     else {         fatalError("Couldn't find \(filename) in main bundle.")     }     do {         let contents = try String(contentsOf: file, encoding: String.Encoding.utf8 )         let lines = contents.split(separator:"\n")         print(contents)         print(lines)         myCounter = lines.count         print(myCounter)         text = String(myCounter)         } catch {             return (error.localizedDescription)         }         return text } This is the content of the text file: "Text 1"; "Text 2"; "Text 3";
2
1
3.8k
Sep ’21
isHidden
I learn how to code. The guided project "Personality Quiz" of the book "App development with swift" ios11 Edition Xcode 9 troubles me. Those lines show no effect in the simulator:         singleStackView.isHidden = true         multipleStackView.isHidden = true         rangedStackView.isHidden = true Why?
2
0
480
Mar ’21