[Solved] Swift Array append not appending values but replacing it

There is not enough information but I can guess you where you have made mistake. Your class Bookmark is not singleton class so,every time Bookmark() create new instance every time. that means it will create new bookmark object for every instance. What I suggest you is inside func func setBookmark(imageURL:String, title:String, description:String, summary:String, date:String, link:String) … Read more

[Solved] Add every 100 string keys from dictionary in array of strings with comma separator

You just need to group your array elements and use map to join your keys using joined(separator: “, “): extension Array { func group(of n: IndexDistance) -> Array<Array> { return stride(from: 0, to: count, by: n) .map { Array(self[$0..<Swift.min($0+n, count)]) } } } Testing: let dic = [“f”:1,”a”:1,”b”:1,”c”:1,”d”:1,”e”:1, “g”: 1] let arr = Array(dic.keys).group(of: 2).map{ … Read more

[Solved] i want create a CollectionView for images with auto scrolling like loop

Use this code. I hope this helps you. Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(moveToNextPage), userInfo: nil, repeats: true) @objc func moveToNextPage (){ if self.x < dataArray.count { let indexPath = IndexPath(item: x, section: 0) sliderPageCont.currentPage=x sliderColletion.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) self.x = self.x + 1 } else { self.x = 0 } } solved … Read more

[Solved] Convert Swift 2 code to Swift 3

Does this work? let size = text.boundingRect(with: CGSize(width: view.frame.width – 26, height: 2000), options: NSStringDrawingOptions.usesFontLeading.union(.usesLineFragmentOrigin), context: nil).size 2 solved Convert Swift 2 code to Swift 3

[Solved] Check if the player has hit a margin

Use SpriteKit. You can select this when creating a new project, choose Game, and then select SpriteKit. It’s Apple’s framework to make games. It has what you will need, and is also faster – don’t make games in UIKit. Within SpriteKit, you have the update() method, as part of SKScene. Do NOT use a while … Read more

[Solved] String prefix and Suffix separated by “: ” in Swift [closed]

You can use regular expression “(?<!:) ” to replace the white spaces ” ” occurrences where it is not preceded by colon punctuation “:”: let string = “Apple: Fruit Tomato: Vegetable Iron: Material” let pattern = “(?<!:) ” let result = string.replacingOccurrences(of: pattern, with: “\n”, options: .regularExpression) print(result) // “Apple: Fruit\nTomato: Vegetable\nIron: Material\n” solved String … Read more

[Solved] How to create JSON Codable using Swift [closed]

This is a starting point. The structs are pretty straightforward. If one of the Division arrays is empty – asked in one of your previous questions – the corresponding array is empty, too. struct Root : Decodable { let status : Bool let data: DivisionData } struct DivisionData : Decodable { let school, college, office, … Read more

[Solved] TableViewCell in Swift?

This should be about right: func tableView(tableView: UITableView, indexPath: NSIndexPath) { let cell = tableView.cellForRowAtIndexPath(indexPath); let cellText = cell.textLabel.text; } 4 solved TableViewCell in Swift?

[Solved] swift date and time ios [closed]

That should do the trick: let date = NSDate() let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = “yyyy-MM-dd” let timeFormatter = NSDateFormatter() timeFormatter.dateFormat = “HH:mm:ss.S” println(dateFormatter.stringFromDate(date)) println(timeFormatter.stringFromDate(date)) 2 solved swift date and time ios [closed]