Post

Replies

Boosts

Views

Activity

Reply to Problems updating a variable
The problem now, is that when you activate your NFCReader, it does not immediately return the tag... ...so you can not immediately assign reader.tagUID To solve this, in NFCReader we can "Publish" the tagCode... ...and in the View, we show this published value. Then, when NFCReader gets the tagCode, it will automatically update your SwiftUI View. Try this: import SwiftUI import CoreNFC struct ContentView: View { @StateObject private var reader = NFCReader() var body: some View { VStack{ Text(reader.tagUID) Button { reader.activate() } label: { Text("Scan") .font(.title) }.padding() } } } class NFCReader: NSObject, ObservableObject, NFCTagReaderSessionDelegate { @Published var tagUID = "UID" var session: NFCTagReaderSession? func activate() { self.session = NFCTagReaderSession(pollingOption: .iso14443, delegate: self) self.session?.alertMessage = "Hold Your Phone Near the NFC Tag" self.session?.begin() } func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) { print("Session Begun!") } func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) { print("Error with Launching Session") } func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) { print("Connecting To Tag") if tags.count > 1{ session.alertMessage = "More Than One Tag Detected, Please try again" session.invalidate() } let tag = tags.first! session.connect(to: tag) { [self] (error) in if nil != error{ session.invalidate(errorMessage: "Connection Failed") } if case let .miFare(sTag) = tag{ let UID = sTag.identifier.map{ String(format: "%.2hhx", $0)}.joined() print("UID: \(UID)") print(sTag.identifier) session.alertMessage = "UID Captured" session.invalidate() DispatchQueue.main.async { self.tagUID = "\(UID)" } } } } }
Jan ’22
Reply to Installing app from TestFlight into Simulator
Have you tried it?
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
Is it possible to upload the json data file, like this? data.json
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
Can you share the equivalent of this screenshot, to check the details of the json file?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
I am not saying that your code will magically start working! I am saying that using the code that you have posted, I am able to make a working app.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
This is what I've got, so far.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
The JSON works okay for me. employeeModel.person.count is 5, as expected. Xcode 13.2.1 (13C100) Where exactly are you seeing the error (which line of code)?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Problems updating a variable
Did that help you, @00ri?
Replies
Boosts
Views
Activity
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
Can you share the code that populates your date model from the json?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to iPad App existing, now want to add MacOs App
You can try this; On App Store Connect, go to the TestFlight page... ...then to your testers... ...and Enable "Test iPhone and iPad Apps on Apple Silicon Macs"
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to MacOS Xcode not loading Images from the Assets
Perhaps the Asset files have not been associated with the macOS target? (Check the "Target Membership" in File Inspector)
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to MacOS Xcode not loading Images from the Assets
Can you show your code for the preview?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to iPad App existing, now want to add MacOs App
On App Store Connect, go the the app's page, then "Pricing and Availability" Go to the section iPhone and iPad Apps on Apple Silicon Macs Check "Make this app available"... ...and select the version of macOS you want to target
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to SF Symbols 3 Vaccine Icon
No.
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Help!! I only Get this error “type () cannot conform to view”
In SwiftUI, you can't just put arbitrary code in a viewBuilder which is expecting a view. Try: List { // var Produkt = [""] // Produkt.append(ScannedCode) Section(header: Text("Produkt")) { Text(Produkt[1]) Text(Produkt[2]) } ...you will have to append your ScannedCode somewhere else!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Problems updating a variable
The problem now, is that when you activate your NFCReader, it does not immediately return the tag... ...so you can not immediately assign reader.tagUID To solve this, in NFCReader we can "Publish" the tagCode... ...and in the View, we show this published value. Then, when NFCReader gets the tagCode, it will automatically update your SwiftUI View. Try this: import SwiftUI import CoreNFC struct ContentView: View { @StateObject private var reader = NFCReader() var body: some View { VStack{ Text(reader.tagUID) Button { reader.activate() } label: { Text("Scan") .font(.title) }.padding() } } } class NFCReader: NSObject, ObservableObject, NFCTagReaderSessionDelegate { @Published var tagUID = "UID" var session: NFCTagReaderSession? func activate() { self.session = NFCTagReaderSession(pollingOption: .iso14443, delegate: self) self.session?.alertMessage = "Hold Your Phone Near the NFC Tag" self.session?.begin() } func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) { print("Session Begun!") } func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) { print("Error with Launching Session") } func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) { print("Connecting To Tag") if tags.count > 1{ session.alertMessage = "More Than One Tag Detected, Please try again" session.invalidate() } let tag = tags.first! session.connect(to: tag) { [self] (error) in if nil != error{ session.invalidate(errorMessage: "Connection Failed") } if case let .miFare(sTag) = tag{ let UID = sTag.identifier.map{ String(format: "%.2hhx", $0)}.joined() print("UID: \(UID)") print(sTag.identifier) session.alertMessage = "UID Captured" session.invalidate() DispatchQueue.main.async { self.tagUID = "\(UID)" } } } } }
Replies
Boosts
Views
Activity
Jan ’22