How should we code in Xcode Swift 2.2 to catch the error when connecting to a server and the connection encounters a problem such as url is incorrect or server is not started? And how should be catch on the table operations also?
Currently, I have been unable to catch the error and the IOS application just terminates.
Thanks ahead of time.
Below is how I think it should be coded but Xcode says that the code “catch” block is unreachable because there is no errors thrown the the “do” block.
Hold on Marc. I am looking again at the last Swift DASample that you sent me. It has some async code in there. Let me see if I can figure it out myself. I will post what I find.
Got my program working with the async beginGetTable. Pulls one of my tables fine that I tested with. But if I turn off server or put in an incorrect url ( which my customers will do ), I do not get any errors logged. Good thing is that it fails but does not terminate the IOS app.
Went back to the DASample app (Swift) from 3/25/2016 and modified url ( port 8099 to 8098 ) to make it incorrect. Ran and it also failed silently.
I assume that the delegate code fun remoteDataAdapter is the code that would log the connect error. I get no logging from this function of the connect error.
Any suggestions on what I am not including in the code.
Below is the code from the DataAccess.swift file.
@objc class DataAccess : NSObject, DARemoteDataAdapterDelegate {
Just assigning the delegate SHOULD be enough. I’ll have a look tomorrow or Monday. Meanwhile, can you try attaching the delegate to the DAasyncRequest and see if that on triggers? I assume the login event does trigger?
Found one possible solution. Went to a different delegate method. And removed the “@objc” from the function. With the “@objc”, the method would not call. I am looking into that more but I guess it has something to do with optional methods.
Calling the alert from within the delegate is not a good scenario but wanted to show something today. Could not determine how to pass the exception from within the class back to where I was calling the rda.