Posts

Post not yet marked as solved
0 Replies
101 Views
Good afternoon (o; Doing a simple SwiftUI app where it fetches a PDF barcode from a web service to be printed on a thermal label printer. So I use this snippet to fetch the PDF and launch the printing dialog:         let pdfView = PDFView()         pdfView.document = PDFDocument(url: self.url!)         let wnd = NSWindow()         pdfView.autoScales = true         pdfView.displaysPageBreaks = false         wnd.setContentSize(pdfView.frame.size)         wnd.contentView = pdfView         pdfView.print(with: printInfo, autoRotate: false) But the printing dialog appears on the lower left corner of the screen...and when choosing "details" the dialog extends to the offscreen area.... Also no paper size is choosable. thanks in advance richard
Posted
by davorin.
Last updated
.
Post not yet marked as solved
1 Replies
94 Views
Good morning So after few days programming in Swift/SwiftUI with basic JSON APIs I would like to dig deeper for how to load more complex JSONs and how to do JSON POSTs. Currently I was only able to load simple JSONs like: [ { id: 1, name: "A" }, ... ] Couldn't figure out how to load a dictionary successfully as I didn't find any examples, despite when trying to load a nested JSON. Are there any good introductions about GET/POST JSONs in Swift that is somehow easy understandable? Not sure if one of those courses subscription might be a good fit like codewithchris.com/hackingwithswift.com and the like....as you don't see upfront what exactly is covered.... thanks in advance richard
Posted
by davorin.
Last updated
.
Post not yet marked as solved
3 Replies
102 Views
Good afternoon Anyone knows a reason why this fails to build? Text(order.firstName + " " + order.lastName + "\n" + order.address + "\n" + order.ZIP + " " + order.city) Gives always: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions But this works: Text(order.firstName + " " + order.lastName + "\n" + order.address) Is there a limit of number of lines I could use with Text()? thanks in advance richard
Posted
by davorin.
Last updated
.
Post not yet marked as solved
0 Replies
113 Views
Good afternoon (o; After two days learning Swift/SwiftUI I have a little app running that retrieves JSON data from our online shop with a TabView showing: Stats for today/week/month etc... Last 2000 orders in a List with a detailed view I use the .onAppear() method to fetch the JSON for the orders list but also .refreshable to update it on demand: .refreshable { fetch.reload() } .onAppear { self.fetch.reload() } But this has the side effect that when I open the order details view and go back, that the JSON is reloaded. Is there a better approach to have the view initialized on startup? Or should I just add an init() method to the JSON fetching model which in turn calls reload()? thanks in advance richard
Posted
by davorin.
Last updated
.
Post not yet marked as solved
3 Replies
141 Views
Good afternoon (o; Finally I installed XCode to give Swift and SwiftUI a try two days ago and already have a simple iOS app running which fetches revenues statistics and online shop orders from our online shop with JSON. Well still some fiddling to do with the layout and looks.... Currently the list view shows all orders sorted by descending order date without any grouping/sections with: struct OrderView: View { @ObservedObject var fetch = FetchOrders()     var body: some View { NavigationView { List (fetch.orders) { order in NavigationLink { OrderDetailView(order: order) } label: { OrderRow(order: order) } } .refreshable { fetch.reload() } .onAppear { self.fetch.reload() } .navigationTitle("Orders") } .navigationViewStyle(DoubleColumnNavigationViewStyle()) .padding()     } } The JSON returned from our server also contains the order date which is currently not used/displayed. So my question....can the List view be made up with section per order date? Seen an old post explaining this, but not sure if that is a rather old method which should be avoided: https://developer.apple.com/forums/thread/128145 I guess in the snippet above there are already other mistakes...but I am just learning since two days and it is quite fun and I was surprised what could be done in this short time compared to Xojo (o; thanks in advance richard
Posted
by davorin.
Last updated
.