swift3

Swift 3.0 Remove duplicates in Array of Dictionaries

烈酒焚心 提交于 2019-12-19 10:27:40
问题 I am working removing the duplicate Dictionaries in an array of Dictionaries in swift 3.0 The below is the let Dict1 : [String : String] = ["messageTo":"Madhu"] let Dict2 : [String : String] = ["messageTo":"Kiran"] let Dict3 : [String : String] = ["messageTo":"Raju"] var arrOfDict = [[String:String]]() arrOfDict.append(Dict1) arrOfDict.append(Dict2) arrOfDict.append(Dict1) arrOfDict.append(Dict3) arrOfDict.append(Dict2 print(arrOfDict) //prints [["messageTo": "Madhu"], ["messageTo": "Kiran"],

Firebase crashes unreadable

て烟熏妆下的殇ゞ 提交于 2019-12-19 10:26:13
问题 I have a problem reading crash reports on FireBase, my reports look like: I've already followed these instructions to symbolicate the stacktrace, got the same result. I'm using Xcode 8 My app is made in Swift 3 Already wrote "FIRApp.configure()" in my appDelegate.didFinishLaunchingWithOptions method, did make it crash, deattach the debbuger, fix the error, re-run the app, got message "Crash successfully uploaded", etc... I'm using pods(pod 'Firebase' and pod 'Firebase/Crash') I see in the

I want to shake the google map marker in iOS Swift

别等时光非礼了梦想. 提交于 2019-12-19 10:12:48
问题 I am working on a project where I wants to shake the marker on google Map. I am using the custom marker icon to represent on the map. Like a head of person is shaking. I don't know how to do it and search a lot but didn't find any solution. 回答1: You can add a CAKeyframeAnimation or CABasicAnimation to your marker.iconView!.layer we add a UIView with a frame bigger than our UIImageView inside then we need to adjust the anchor point of your UIImageView to bottom in vertical and horizontally

How to select Swift toolchains when building with Carthage

北城以北 提交于 2019-12-19 10:08:15
问题 I am creating an iOS app and use Carthage to build external libraries. Since the libraries I use are currently both Swift 2 and Swift 3 I am in a bit of a squeeze. Thus I want to have one Swift 2 branch and one Swift 3 branch for development and then merge them when the libraries are all Swift 3 compatible. However, I am not able to select which toolchain for build for with Carthage (version 0.18). Here is the contents of my Cartfile: # Swift 2 libraries github "stephencelis/SQLite.swift" ~>

Extra argument 'method' in call of Alamofire

独自空忆成欢 提交于 2019-12-19 10:07:35
问题 I've searched for this issue and there are many answers available but none are solving. I've defined parameters as: let parameters = [ "name": username, "mobile": "", "email": email, "password": "", "blood_donor": "0", "registration_id": defaults.string(forKey: "FCMToken"), "platform": platform, "appID": "3" ] And after that when I send the request: Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding(), headers: headers).responseJSON { response in So I get a

URL is always nil in Swift 3

微笑、不失礼 提交于 2019-12-19 10:06:10
问题 I have a struct that I am using to call out to the iTunes API. But when ever I run it myURL variable is never getting set, it's always nil . Not sure what I am doing wrong: let myDefaultSession = URLSession(configuration: .default) var myURL: URL? var myDataTask: URLSessionTask? struct APIManager { func getJSON(strURL: String) { myURL = URL(string: strURL) var dictReturn: Dictionary<String, Any> = [:] //cancel data task if it is running myDataTask?.cancel() print(myURL!) //<----Always nil } }

Cast to different C struct unsafe pointer in Swift

南笙酒味 提交于 2019-12-19 10:05:14
问题 I want to call the Posix socket functions socket and bind from Swift. socket is pretty easy—it takes Int32 s, but bind is causing a problem, because I have a sockaddr_in pointer, but it wants a sockaddr pointer. In C, this would be a cast, like: bind(sock, (struct sockaddr *)&sockAddress, sizeof(sockAddress)) Here's an attempt in Swift: let sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) var sockAddress = sockaddr_in() bind(sock, &sockAddress, UInt32(MemoryLayout<sockaddr_in>.size)) The bind

How to compare Range<String.Index> and DefaultBidirectionalIndices<String.CharacterView>?

这一生的挚爱 提交于 2019-12-19 09:24:40
问题 This comparison worked in Swift 2 but doesn't anymore in Swift 3: let myStringContainsOnlyOneCharacter = mySting.rangeOfComposedCharacterSequence(at: myString.startIndex) == mySting.characters.indices How do I compare Range and DefaultBidirectionalIndices? 回答1: From SE-0065 – A New Model for Collections and Indices In Swift 2, collection.indices returned a Range<Index> , but because a range is a simple pair of indices and indices can no longer be advanced on their own, Range<Index> is no

Swift 3: How to center horizontally the last row of cells in a UICollectionView with only one section?

和自甴很熟 提交于 2019-12-19 09:14:24
问题 I'm using a UICollectionView with only one section. Here's some visualization: [ x x x ] [ x x x ] [ x x ] If the last row in the UICollectionView does not have all 3 cells filled, I'd like to center those cells like so: [ x x x ] [ x x x ] [ x x ] I've tried to implement solutions from the following places: How to center horizontally UICollectionView Cells? How to center align the cells of a UICollectionView? However, the solutions shifts all the cells, and I'd like to only shift the LAST

What's the difference between tableView.reloadData and tableView.reloadRows? [duplicate]

a 夏天 提交于 2019-12-19 08:17:27
问题 This question already has answers here : TableView reloadData vs. beginUpdates & endUpdates (3 answers) Closed 2 years ago . What is the difference between tableView.reloadData() and tableView.reloadRows(at: [IndexPath],with: .none) ? I know that cells will reload everything after tableView.reloadData() I tried the following. cell.count = 2 indexPath = [0,0] and [0,1] tableView.reloadRows(at: [[0,0] as IndexPath],with: .none) tableView.reloadRows(at: [[0,1] as IndexPath],with: .none) However,