swift2

How can I use Swift 2.2 on Xcode8?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 11:01:58
问题 I had a project on Swift2.3 and XCode7 . It worked well. When I have updated it to XCode8 and Swift3 the project does not show anything on the emulator so I decided to use, at least by the moment, Swift2.2 on Xcode8 (I have a copy of the project in Swift2.2 ) but it gives to me the following error: “Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift

How can I use Swift 2.2 on Xcode8?

穿精又带淫゛_ 提交于 2020-01-02 10:59:28
问题 I had a project on Swift2.3 and XCode7 . It worked well. When I have updated it to XCode8 and Swift3 the project does not show anything on the emulator so I decided to use, at least by the moment, Swift2.2 on Xcode8 (I have a copy of the project in Swift2.2 ) but it gives to me the following error: “Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift

GoogleDrive + Alamofire: Uploading a file with properties

此生再无相见时 提交于 2020-01-02 09:29:10
问题 I am trying to upload a file + parameters to Google Drive via Swift 2/Alamofire. In the code below, i I change the line that says: "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart" to the following: "https://www.googleapis.com/upload/drive/v3/files" the file uploads to google without a name. Otherwise, the file upload fails with the same generic code: Error Domain=com.alamofire.error Code=-6003 "Response status code was unacceptable: 400" UserInfo=

Alamofire with google geocoding api

痴心易碎 提交于 2020-01-02 09:10:51
问题 In one of my apps I need to geocode address string. At first I considered using CLGeocoder . However, after I tried it I stumbled upon a problem which I described in this question. The solution was to use Google's Geocoding APIs instead. I have now switched to them and managed to get them working by having the following functions: func startConnection(){ self.data = NSMutableData() let urlString = "https://maps.googleapis.com/maps/api/geocode/json?address=\(searchBar.text!)&key=MYKEY" let

How to reload tableview after delete item in cell Swift 2

亡梦爱人 提交于 2020-01-02 07:35:07
问题 I have a list of accounts in a TableView . After I press a button, an item is deleted. So far so good. How to refresh tableView after deletion? Please find the below screenshot for more information. TableView is in another ViewController, the button to delete is in a ViewControllerCell class cellAccount: UITableViewCell { @IBOutlet weak var imgAccount: UIImageView! @IBOutlet weak var lblNomeAccout: UILabel! @IBOutlet weak var btnDeletar: UIButton! @IBAction func btnDeletar(sender: AnyObject)

How to convert bytes to NSString after AES CryptoSwift cipher

左心房为你撑大大i 提交于 2020-01-02 07:03:48
问题 I am using CryptoSwift to encrypt data I will be passing in a URL. To do this, I need the datatype of the piece of data to be a String to concatenate into the NSURL request. After encrypting the data it is output in bytes. How can I cast the bytes to a nonsense string to pass in the URL that a PHP script can decrypt? I am able to encrypt into UInt8, however I do not think it is possible to pass it over a URL to PHP script so I need to make it a string. The code: let string = "hello" let input

How to remove node from parent if touched more than once?

僤鯓⒐⒋嵵緔 提交于 2020-01-02 07:01:44
问题 I am making a game in which bullets are shot to the bad guy when the button is pressed. I made a function in which whenever it is called it adds more bad guys. Here is the code: (This method is called multiple times) func BadGuyPosition() let BadGuyCircle = SKSpriteNode(imageNamed: "CircleBadGuy") BadGuyCircle.zPosition = 1 //var mininmum = self.size.width / 600 let TooMuch = self.size.height - 60 let PointToShow = UInt32(TooMuch) BadGuyCircle.position = CGPointMake(CGRectGetMaxX(self.frame)

How to remove node from parent if touched more than once?

半腔热情 提交于 2020-01-02 07:01:43
问题 I am making a game in which bullets are shot to the bad guy when the button is pressed. I made a function in which whenever it is called it adds more bad guys. Here is the code: (This method is called multiple times) func BadGuyPosition() let BadGuyCircle = SKSpriteNode(imageNamed: "CircleBadGuy") BadGuyCircle.zPosition = 1 //var mininmum = self.size.width / 600 let TooMuch = self.size.height - 60 let PointToShow = UInt32(TooMuch) BadGuyCircle.position = CGPointMake(CGRectGetMaxX(self.frame)

Swift 2 addObserver for specific textField with the object parameter

落爺英雄遲暮 提交于 2020-01-02 06:38:26
问题 To my understanding the object parameter of the addObserver method is the object you want to receive notifications from. Most of the time I see it as nil (I assume this is because notifications of the specified type are wanted from all objects). In my particular case I have a text field at the top of the screen and at the bottom of the screen and I want the view to move up only when the user taps the bottom text field, not the top one. So I call the following method in viewWillAppear func

Enum case switch not found in type

邮差的信 提交于 2020-01-02 01:21:06
问题 Can someone please help me with this. I have the following public enum public enum OfferViewRow { case Candidates case Expiration case Description case Timing case Money case Payment } And the following mutableProperty: private let rows = MutableProperty<[OfferViewRow]>([OfferViewRow]()) In my init file I use some reactiveCocoa to set my MutableProperty: rows <~ application.producer .map { response in if response?.application.status == .Applied { return [.Candidates, .Description, .Timing,