swift2

Drag & Drop from TableView to Another View in Swift

╄→гoц情女王★ 提交于 2019-12-12 08:54:00
问题 I'm trying to copy an item from one UITableView to another View and I've been banging my head over this for the past 2 days and still i am not able to figure out how to accomplish this. Here is a little sketch of my UI architecture Here is what i am doing Long Press on a row in the tableview Create a snapshot of the image in the cell when long pressed Drag the snapshot to the View(Green area) outside the table view When released check whether the snapshot was dropped in the Green View Area. I

Swift Infinite Fade in and Out Loop

白昼怎懂夜的黑 提交于 2019-12-12 08:40:52
问题 How can I make a effect in swift similar to this: I want the animation to loop forever. 回答1: For iOS UIViewAnimationOptions set provides different handy options to achieve a combination of beautiful and complex animations. For your particular scenario you will require two of the options. UIViewAnimationOptions.Repeat UIViewAnimationOptions.AutoReverse Check out the code below for implementation. Code : class MyViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad(

CocoaPods - build for iOS 9 / Swift 2 with Xcode-beta

雨燕双飞 提交于 2019-12-12 08:32:59
问题 I have a "CocoaPod" (terminology?) that's currently at version 1.1. There's also a develop branch of the repo that requires Swift 2.0 (so needs a base SDK of IOS 9.0) with a PodSpec as follows: Pod::Spec.new do |s| s.name = 'ReachabilitySwift' s.version = '2.0-beta1' s.homepage = 'https://github.com/ashleymills/Reachability.swift' s.authors = { 'Ashley Mills' => 'ashleymills@mac.com' } s.summary = 'Replacement for Apple\'s Reachability re-written in Swift with callbacks.' s.license = { :type

Failed to launch IBCocoaTouchImageCatalogTool via CoreSimulator spawn

萝らか妹 提交于 2019-12-12 08:17:48
问题 I have an Xcode project which was downloaded from the internet so I don't know which Xcode version was used to write it but the language is Swift 2. I opened it in Xcode 7.1 beta 1 and I get the following compile time error. Failed to launch IBCocoaTouchImageCatalogTool via CoreSimulator spawn I deleted the DerviedData foler, cleaned and build the project several times. Tried converting the project to latest Swift syntax but it says there's nothing to convert. I'm all outta ideas. Suggestions

Generate Array of Unique Random Numbers within Inclusive Range

余生长醉 提交于 2019-12-12 07:12:38
问题 I am trying to write a function in Apple Swift (iOS) that will generate any given amount of unique random numbers that are within a given inclusive range, say between 0 and 10. So if I say I want 5 unique random numbers between 0 and 10, it would return an array with [7, 10, 2, 3, 0] or [7, 10, 2, 8, 0], etc. I have that part working with: // Returns an array of unique numbers func uniqueRandoms(numberOfRandoms: Int, minNum: Int, maxNum: UInt32) -> [Int] { var uniqueNumbers = [Int]() while

Converting Swift 1.2 code to Swift 2

十年热恋 提交于 2019-12-12 06:19:29
问题 I've tried for 15 minutes trying to figure out how to use this code from a book which was written before Swift 2, in an Xcode 7 app in Swift 2. Here's the code snippit: self.coreMotionManager.accelerometerUpdateInterval = 0.3 self.coreMotionManager.startAccelerometerUpdatesToQueue(NSOperationQueue(), withHandler: { (data: CMAccelerometerData!, error: NSError!) in if let constVar = error { println("There was an error") } else { self.xAxisAcceleration = CGFloat(data!.acceleration.x) } }) I get

Parsing JSON in swift 2.0

淺唱寂寞╮ 提交于 2019-12-12 06:06:44
问题 I'm trying to parse JSON data from a server api. The json : [ {"interest": { "title":"Sport", "sub":[ "painting", "photography", "museum"] } }, {"interest": { "title": "music", "sub": [ "rock", "classic", "techno"] } }] The code to get it from a file just to test to parse it : do{ let path = NSBundle.mainBundle().pathForResource("MainInterest", ofType: "json") let jsonData = NSData(contentsOfFile: path!) let jsonResult:NSArray! = try NSJSONSerialization.JSONObjectWithData(jsonData! , options:

Save nearest establishment to google user account in Swift2

冷暖自知 提交于 2019-12-12 05:25:41
问题 The purpose for this portion of the app is for the user (signed in with Google sign in) to locate the nearest place to them and save it automatically to the user's google account. The below method works fine, grabbing the most likely place the user is located at (first object in the array of placeLikelihoods). Now what I need to do is save it to the user's google account (the one they signed in with). Any lead or ideas on how to do this or if it's even possible? Thank you for the help like

Why “tableview.cellForRowAtIndexPath(indexPath)” give me a BAD_ACCESS error?

邮差的信 提交于 2019-12-12 05:24:35
问题 I attempted to use this method to get the cell of that indexPath, but I got this "EXC_BAD_ACCESS" error. But if I use self.tableView(tableView, cellForRowAtIndexPath:indexPath) , it works fine. I am confused what's the difference between that two methods? 回答1: Using self.tableView(tableView, cellForRowAtIndexPath:indexPath) is the code is your View Controller, and it dequeue's a suitable new cell. Whereas, the cellForRowAtIndexPath method on the table view returns nil if the cell is not

Define object with multidimensional properties [duplicate]

烂漫一生 提交于 2019-12-12 05:07:30
问题 This question already has an answer here : Table view from array index out of range (1 answer) Closed 4 years ago . PROBLEM: What I'm looking for is to display this info in a table so I think I need: MyHouses1[section][row].getAddressDetails() How do I properly define MyHouses1? import UIKit class House { var address = "Address" var street = "Street" var city = "City" var state = "State" var zip = "Zip" func getAddressDetails() -> String { return "\(address) \(street) \(city) \(state) \(zip)"