Posts

Post marked as solved
6 Replies
4.1k Views
Hello all:I am getting JSON data from a URL and then putting it into an array, and then I need to get that data into an array of objects. Here is the struct and array (actual names hidden for confidentiality):struct sTest: Codable { var a: String var b: String var c: String var d: String var e: String var f: String var g: String }var sTestArray = [sTest]()and I get the data from the URL using this code snippetif let jsonObj = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? NSDictionary{ let theList: NSArray = jsonObj["data"] as! NSArrayand when I print the array in the Console, this is what I get:Success{ data = ( { a = "a value"; b = "b value"; c = "c value"; d = "d value"; e = "e value"; f = "f value"; g = "g value"; }, and there are 144 data elements.I am stuck on parsing this into the sTestArray. I have tried setting up a decoder, and also tried using array indexes, but no joy. Can anyone offer any assistance?Thanks in advance!John.
Posted Last updated
.
Post not yet marked as solved
0 Replies
665 Views
Hello All: I am working on an APP that connects to an IOT device via BLE Library, and I set a bunch of keys in my info.plist the library requires: Privacy - Bluetooth Always Usage Description Privacy - Bluetooth Peripheral Usage Description Privacy - Local Network Usage Description Privacy - Bluetooth Always Usage Description Privacy - Location Always and When in Use Usage Description Privacy - Location Always Usage Description Privacy - Location Usage Description Privacy - Location When In Use Usage Description but when I start the App from XCode, it does not ask for the "Local Network" authorization, and in the Privacy settings on the iPhone the App is not listed on the Local Network Screen, nor does Local Network appear when I look at the App properties. Can anyone make a suggestion? Thanks!
Posted Last updated
.
Post not yet marked as solved
0 Replies
443 Views
Hello all: I am testing an app that uses a BLE library to connect to an IOT device. The Library requires both Bluetooth and Location services, so I added entries to the info.plist file. On my iPhone when I go into the App settings I see BT enabled, but under Privacy-Location Services, the App is not there. I am thinking I added the entries to info.plist incorrectly? Under "Information Property List" I added: Privacy - Bluetooth Always Usage Description Privacy - Location Always Usage Description and then I also added: Required Device Capabilities Item 0: Bluetooth Low Energy Item 1: Location Services Thanks for any and all input
Posted Last updated
.
Post marked as solved
2 Replies
1.6k Views
Hello all:I have a collectionview using a custom cell that has 2 buttons in each cell. I need to display an alert to the User when a button is tapped, and tried this:@IBAction func testButton_Tapped(_ sender: Any) { print("Test Button tapped") let alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert) let defaultAction = UIAlertAction(title: "Close", style: .default, handler: nil) alertController.addAction(defaultAction) self.present(alertController, animated: true, completion: nil) }but I get an error: Value of type 'DeviceCell' has no member 'present'. Note the function works, I get the print statement.The alert does work if I put it in the ViewController extension here:func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath){}but it only works then if I tap the Cell itself, not the button.Any and all input is appreciated!John.
Posted Last updated
.
Post marked as solved
6 Replies
494 Views
Hi all:I am working on a POC IOS app that needs to authtenticate to a SA+QL Server Azure database. I wrote a web service in .NET, also osted on Azure, and found some examples that let me write the code below in my IOS app. So when the user taps the login button, the function calls the submitPost code, and the line print("response: ", utf8Representation) prints the response to the console. The web service will return "Success" if the authentication creentials are valid, and I need to return this value back to the login button function so I can take action based on the result, but I've been struggling trying to figure out how. Can anyone offer a suggestion? Note this is just a POC so if this isn't the best way to do this I am not worried about it right now, just need this to work! Thanks for any and all input!Code in Login Function>>>let myPost = User(username: "User1", password: "PW") submitPost(post: myPost) { (error) in if let error = error { fatalError(error.localizedDescription) } }Submit function>>>func submitPost(post: User, completion:((Error?) -> Void)?) { var urlComponents = URLComponents() urlComponents.scheme = "https" urlComponents.host = "mysite1.azurewebsites.net" urlComponents.path = "/Authenticate" guard let url = urlComponents.url else { fatalError("Could not create URL from components") } var request = URLRequest(url: url) request.httpMethod = "POST" var headers = request.allHTTPHeaderFields ?? [:] headers["Content-Type"] = "application/json" request.allHTTPHeaderFields = headers let encoder = JSONEncoder() do { let jsonData = try encoder.encode(post) request.httpBody = jsonData print("jsonData: ", String(data: request.httpBody!, encoding: .utf8) ?? "no body data") } catch { completion?(error) } let config = URLSessionConfiguration.default let session = URLSession(configuration: config) let task = session.dataTask(with: request) { (responseData, response, responseError) in guard responseError == nil else { completion?(responseError!) return } if let data = responseData, let utf8Representation = String(data: data, encoding: .utf8) { print("response: ", utf8Representation) } else { print("no readable data received in response") } } task.resume() }
Posted Last updated
.
Post not yet marked as solved
0 Replies
271 Views
Hi all:trying to update from XCode 11.1 to 11.2, and I see the progress button for a while, and then it fails with the message "Unable to download app. "Xcode" could not be installed. Please try again later". So I tried again later, tried rebooting, etc. no joy. Can anyone offer any suggestions?TIA.John.
Posted Last updated
.
Post marked as solved
2 Replies
508 Views
Hello all:I have a very simple IOS app in Swift that has 3 buttons on it. I used the assitant editor and teh <ctrl> key click and drag to create the functions for the buttons:@IBAction func button1_Tap(_ sender: Any){ print("Button 1") }@IBAction func button2_Tap(_ sender: Any){ print("Button 2") }@IBAction func button3_Tap(_ sender: Any){ print("Button 3") }but for some reason, tapping any of the buttons fires all 3 functions.Any ideas are appreciated!John.
Posted Last updated
.
Post not yet marked as solved
2 Replies
4.2k Views
Hello all:I am working on a POC and require a framework file compiled by a hardware manufacturer, which was compiled in Swift 4, and so I have to work on the project in Xcode 10.2 (I think). I can run in the simulator OK, but when I try to run on my iPhone i get a message:"Could not locate device support files. This iPhone 8 (Model A1863, A1905, A1906, A1907) is running iOS 13.1.2 (17A860), which may not be supported by this version of Xcode."Can anyone suggest an idea? I thought about recompiling the framework in the latest version of XCode, but I guess I need the source for that? Is it possible to install the files needed for this iPhone to XCode 10.2?Thanks in advance for any and all input.John.
Posted Last updated
.