Posts

Post not yet marked as solved
0 Replies
290 Views
Hi,With reference to https://forums.developer.apple.com/thread/129860 I am looking for a way to trigger an event when the user scrolls down to the end of a List.Recommended solution from the thread above mentionsfunc tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCellas a solution and then to look at the index of the current cell.My List looks like thisList(warehouseOrderController.warehouseOrders){ warehouseOrder in NavigationLink(destination: WarehouseOrderView(warehouseOrder: warehouseOrder) .environmentObject(self.settingStore) ){ OrderTableRow(warehouseOrder: warehouseOrder) } }So the question is: how do I get the index of the current row displayed and how do I trigger a function when the user reaches row 900/1000?
Posted
by bobandsee.
Last updated
.
Post marked as solved
5 Replies
1.4k Views
Hi,I am fetching data for my table view via a web service. Based on the request the result set can vary between 1 row and 20,000 rows. I know that usually my users are just interested in the first 1,000 rows of the data so I am wondering to have an approach where the initial web service call just loads the top 1,000 rows and when the user scrollls down the list and gets to the 800s, 900s or end of table, another request is triggered to fetch the next 1,000 rows - kinda similar to a Twitter feed where the data gets loaded once you scrolld down.What would the events be to trigger the call for the next set of data or is there another way to make this happen?Max
Posted
by bobandsee.
Last updated
.
Post not yet marked as solved
0 Replies
264 Views
Hi,Is there a way to navigate to another view after tapping a row WITHOUT using NavigationLink (see here why the NavigationLink gives me a headache: https://forums.developer.apple.com/thread/128454)I have tried@State private var presentDetails: Bool = falseandList(warehouseOrderController.warehouseOrders){ warehouseOrder in OrderTableRow(warehouseOrder: warehouseOrder).onTapGesture { print(warehouseOrder.orderRef!) self.presentDetails = true }.sheet(isPresented: self.$presentDetails){ WarehouseOrderView(warehouseOrder: warehouseOrder).environmentObject(self.settingStore) } }but that always brings the new view up as a modal while I actually want it to look like as if I had used the NavigationLink (meaning: not floating over the other view).Any ideas?Max
Posted
by bobandsee.
Last updated
.
Post marked as solved
7 Replies
1.5k Views
Hi,From my ContentView I use a NavigationLink to go to an Order Overview WarehouseOrderOverview()NavigationView{ ScrollView{ VStack{ NavigationLink(destination: WarehouseOrderOverview().environmentObject(self.settingStore).navigationBarTitle("Orders")) { MenuButtonNavigation(title: "Order overview", color: Color.gray, icon: "doc.text.magnifyingglass").padding(.top) }WarehouseOrderOverview:var body: some View { List(warehouseOrderController.warehouseOrders){ warehouseOrder in NavigationLink(destination: WarehouseOrderView(warehouseOrder: warehouseOrder).environmentObject(self.settingStore).navigationBarTitle("Details")){ OrderTableRow(warehouseOrder: warehouseOrder) }So far so good. If I now tap a row in that view, I get to the order details view WarehouseOrderViewNavigationView{ ScrollView() { VStack{ VStack(spacing: -25) { HStack(spacing: -25) { NavigationLink(destination: WarehouseOrderLinesView(warehouseOrderLines: warehouseOrderLineController.warehouseOrderLines)){ TaskSummaryView(title: "Total Lines", color: .blue, icon: "list.dash", value: warehouseOrderLineController.warehouseOrderLines.count) }Problem is now that when I tap the TaskSummaryView, it opens the WarehouseOrderLinesView with two navigation bars on top (one going back to Orders, the other one to the Order details [too bad I cannot post a screenshot here ...])I believe the issue is that I create a new NavigationView in my WarehouseOrderView but I get an error when trying to use the NavigationLink without embedding it in a NavigationView. Or is there a better way than NavigationLink to open the view WarehouseOrderLinesView?Max
Posted
by bobandsee.
Last updated
.
Post not yet marked as solved
3 Replies
1.6k Views
I have this code in my SwiftUI view structHStack{ Text("Direction") Spacer() Picker("Direction", selection: $selectorIndex) { ForEach(0 ..< directions.count) { index in Text(self.directions[index]).tag(index) } } .pickerStyle(SegmentedPickerStyle()) } Picker("From status", selection: $fromStatus2) { ForEach(Self.orderStatusFromArray, id: \.self) { status in Text(status) } }So far so good. If I now break it on purpose by changing line 12 toPicker("From status", selection: "025") {Xcode now indicates that there is an error on line 06Generic parameter 'S' could not be inferred 1. In call to initializer (SwiftUI.Text)Shouldn't it rather indicate that the error is on line 12 instead of 6?Max
Posted
by bobandsee.
Last updated
.
Post not yet marked as solved
2 Replies
4.5k Views
Hi,I have this pickerPicker("From status", selection: $fromStatusSelectorIndex) { ForEach(0 ..< orderStatusFromArray.count) { index in Text(self.orderStatusFromArray[index]).tag(index) } }that is using data from this array:private var orderStatusFromArray: [String] = ["005", "010", "022", "025", "030", "035", "040", "045", "046", "047", "060"]When saving my values, I store the picker selection in UserDefaultsself.settingStore.defaults.set(self.orderStatusFromArray[self.fromStatusSelectorIndex], forKey: "view.orderHeaderFilter.fromStatus")What I don't understand: where in my code do I have to place it to set the picker to the saved default value? Let's say user saved the settings with status 025 (orderStatusFromArray[3]) - where do I explain to SwiftUI that the picker should be set to 3 when the view is loaded?Max
Posted
by bobandsee.
Last updated
.
Post marked as solved
2 Replies
2.7k Views
Hi,I have this code to change my background color based on the enum AddressTypeenum AddressType: String, CaseIterable{ case shipFrom = "1" case shipTo = "2" case unknown = "999" init(type: String) { switch type { case "1": self = .shipFrom case "2": self = .shipTo default: self = .unknown } } var text: String { switch self { case .shipFrom: return "Ship From" case .shipTo: return "Ship To" case .unknown: return "N/A" } } }.background(addressType.self == AddressType.shipFrom ? Color.green : Color.yellow)Question is now: what do I have to do if I want my shipFrom in Color.green and my shipTo in Color.orange? I have tried adding a 2nd .background() for the shipTo but that did not work.Is there any way to work with more than 1 IF clause?Max
Posted
by bobandsee.
Last updated
.
Post not yet marked as solved
5 Replies
3.6k Views
Hi,I just started playing around with SwiftUI and have stumbled over something: in my "regular" apps, my view controllers take care of loading data from a web service (triggered by a function called in the ViewDidLoad() part) and then hand the information over to the views.If I understand the concept of SwiftUI correctly, this whole piece of loading data is no longer managed in the View files but somewhere outside.So in my app now I have a class of WarehouseOrder and created another class called WarehouseOrderController that is responsible for loading the data from the server and storing it in an array (happens in function loadData() called by the init() of that class)@Published var warehouseOrders:[WarehouseOrder] = []From my main menu I call the View WarehouseOrderOverview via a NavigationLinkstruct WarehouseOrderOverview: View { @EnvironmentObject var settingStore: SettingStore var warehouseOrderController = WarehouseOrderController() var body: some View { List(warehouseOrderController.warehouseOrders){ warehouseOrder in Text(warehouseOrder.orderRef) } } }What I don't get is that when I start the app, it is triggering the init() of WarehouseOrderController already when I am in the main menu. How can I change it that the data only gets loaded when I actally trigger the NavigationLink to WarehouseOrderOverview?Max
Posted
by bobandsee.
Last updated
.
Post not yet marked as solved
1 Replies
755 Views
Hi,I have a web server at https://192.1681.1.12 that I call via URLSession to get some data via XML.I have created my own certificate for the server and when I call the URL via Safari or any other browser, I can display the result. When calling it via iOS in my Xcode simulator from my Mac (192.168.1.8), viafunc parseFeed(feedUrl: String, completionHandler: (([(title: String, description: String, pubDate: String)]) -> Void)?) -> Void{ self.parseCompletionHandler = completionHandler let request = URLRequest(url: URL(string: feedUrl)!) let urlSession = URLSession.shared let task = urlSession.dataTask(with: request, completionHandler: {(data, response, error) -> Void in guard let data = data else { if let error = error { print(error) } return } print(data) let string = String(data: data, encoding: .utf8) print(string) let parser = XMLParser(data: data) parser.delegate = self; parser.parse() }) task.resume() }I get2019-09-01 14:31:17.771371-0400 SimpleRSSReader[98874:12097620] TIC SSL Trust Error [1:0x600002321080]: 3:02019-09-01 14:31:17.772885-0400 SimpleRSSReader[98874:12097620] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)2019-09-01 14:31:17.773050-0400 SimpleRSSReader[98874:12097620] Task <81636F1A-3249-4719-8D20-693D89628016>.<1> HTTP load failed (error code: -1202 [3:-9813])2019-09-01 14:31:17.773227-0400 SimpleRSSReader[98874:12097231] Task <81636F1A-3249-4719-8D20-693D89628016>.<1> finished with error - code: -1202Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.1.12” which could put your confidential information at risk." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x600002428990>, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9813, NSErrorPeerCertificateChainKey=( "<cert(0x7fb187802800) s: Jakob Jenkov i: Jakob Jenkov>"), NSUnderlyingError=0x600001835590 {Error Domain=kCFErrorDomainCFNetwork Code=-1202 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x600002428990>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9813, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9813, kCFStreamPropertySSLPeerCertificates=( "<cert(0x7fb187802800) s: Jakob Jenkov i: Jakob Jenkov>")}}, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.1.12” which could put your confidential information at risk., NSErrorFailingURLKey=https://192.168.1.12:9898/getCasesByClientAndArticle?max=asd&client=TESTCLIENT&depot=UUUU&article=WD076&exactMatch=true, NSErrorFailingURLStringKey=https://192.168.1.12:9898/getCasesByClientAndArticle?max=asd&client=SEQUEL&depot=TOR&article=WD076&exactMatch=true, NSErrorClientCertificateStateKey=0}So what do I need to add or change to explain to Swift that SSL connections to 192.168.1.12 are OK?
Posted
by bobandsee.
Last updated
.
Post not yet marked as solved
3 Replies
523 Views
Hi,I have read that with the flag NSAllowsArbitraryLoads Apple is enforcing communication via HTTPS and all apps that don't support that will not be added to the App Store. Does the same rule apply for apps developed for internal enterprise usage? I have a SOAP web service that is running on HTTP and I want to access that. Is that going to be an issue?Max
Posted
by bobandsee.
Last updated
.