swift3

Swift 3 export SecKey to String

家住魔仙堡 提交于 2019-12-20 14:38:06
问题 I am developing an iOS app using swift 3. I need to export an SecKey (which is the user RSA publickey reference) to a string (e.g base64) in order to share it through a generated QRCode. It also has to work the other way since the other user that scans the QRCode , will be able to rebuild a SecKey reference from the string extracted from the QRCode. I found few tutorials but I don't understand exactly what I need to extract from the SecKey reference, and I don't know how to convert it to a

Swift 3 URLSession with URLCredential not working

微笑、不失礼 提交于 2019-12-20 12:03:29
问题 I am doing a URLSession, but the URL requires credentials. I have this whole method here that is trying to do a URLSession with URLCredentials: func loginUser(_ username: String, password: String, completion: @escaping (_ result: Bool) -> Void) { //Create request URL as String let requestString = String(format:"%@", webservice) as String //Covert URL request string to URL guard let url = URL(string: requestString) else { print("Error: cannot create URL") return } //Convert URL to URLRequest

Swift 3 How to validate server certificate using SSL Pinning and AlamoFire?

走远了吗. 提交于 2019-12-20 11:25:16
问题 I'm writing an app in swift 3 that needs to talk to my server. I have the full certificate chain in der and crt format which I am the CA for(Not to be confused with self signed). How do I use this in my app to validate my server? Below is my rest call and response Rest Call: var request = URLRequest(url: URL(string: "https://myserver/login")!) request.addValue("Content-Type", forHTTPHeaderField: "application/json") request.httpMethod = "GET" let session = URLSession.shared session.dataTask

iOS: Google Maps API - markerInfoWindow vs markerInfoContents

为君一笑 提交于 2019-12-20 10:53:50
问题 I looked through the Google Maps docs and the description does not seem to help much. I'm following an old tutorial that made use of markerInfoContents however, when I used the delegate it didn't return what I expected. With markerInfoContents : My custom view seems to override the default view When I used markerInfoWindow , the results were what I expected: I am simply pulling in a custom UIView from a xib file like so: func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker)

Core Data Codegen fail in Xcode 8

℡╲_俬逩灬. 提交于 2019-12-20 10:32:47
问题 I have an iOS app containing a Core Data model with 6 entities. The entity Name is set up as follows: Class Name: Name Module: Current Product Module Codeine: Class Definition (all 5 other entities are set up similarly). Problem 1 (fixed itself but leaving for posterity) Code IS generated in the derived data folder… not as ~class definitions as expected, but as extensions instead (named like Name+CoreDataProperties.swift . It doesn't seem to matter whether the Codegen is set to Class

Swift 3 WebView

﹥>﹥吖頭↗ 提交于 2019-12-20 10:24:06
问题 So I just updated to the new Xcode8 and Swift3 but now my web view does not work. Here is the code I used: UIWebView.loadRequest(webView)(NSURLRequest(URL: NSURL(string: "http://hardwirestudios.com")!)) Now gives me these two error: 'NSURL' is not implicitly convertible to 'URL'; did you mean to use 'as' to explicitly convert?- 'NSURLRequest' is not implicitly convertible to 'URLRequest'; did you mean to use 'as' to explicitly convert? 回答1: For this exact situation, retype your line to:

Error when build project in new Xcode 8.0 beta

与世无争的帅哥 提交于 2019-12-20 10:19:10
问题 Signing for SWRevealViewController requires a development team. Select a development team in the Target Editor. Code signing is required for product type 'Framework' in SDK 'iOS 10.0' 回答1: I combatted this last night. I assume you are using Pods: For each Pod, change the Team under Signing (as shown here) edit: Screenshots are in Xcode 8 (now) 回答2: I stole this from Anish: Project tab -> list of Targets -> General tab for the target xcode complains about (in my case that's my framework used

'dispatch_once_t' is unavailable in Swift: Use lazily initialized globals instead [duplicate]

旧时模样 提交于 2019-12-20 09:49:57
问题 This question already has answers here : Whither dispatch_once in Swift 3? (7 answers) Using a dispatch_once singleton model in Swift (30 answers) Closed 3 years ago . I am having trouble with dispatch_once_t when migrating to Swift 3. According to Apple's migration guide: The free function dispatch_once is no longer available in Swift. In Swift, you can use lazily initialized globals or static properties and get the same thread-safety and called-once guarantees as dispatch_once provided.

Sorting Array in Swift3

╄→尐↘猪︶ㄣ 提交于 2019-12-20 09:47:41
问题 In my code, I have a struct like the following: struct Object { var name: String var count: Int I am now creating an array of 10 Objects with random names and random counts. Is there an easy way to a) sort them alphabetically b) sort them numerically in ascending order Basically, there will be an array like so: [Object1, Object2, Object3] . Every Object has a name and count attribute, and I want the objects in that list be sorted via these two attributes. Solution in Swift2 (using this

Animated curve line in Swift 3

我的未来我决定 提交于 2019-12-20 09:07:19
问题 I want to draw some bezier lines and I want to animate them with a wave effect, Example Do you have some ideas about how I can do this ? Bezier line is it the best method to do it ? I found only 2 libs for this, but they are not really useful for what I need, I try to modify the code of one lib, unfortunately without success https://github.com/yourtion/YXWaveView I found this lib, https://antiguab.github.io/bafluidview/ which does the work, but it written in obj-c, maybe you know something