[Solved] Format string to date format swift [closed]

You have to changes the format for working in both case: var isoDate = “2018-10-31” let dateFormatter = DateFormatter() dateFormatter.dateFormat = “yyyy-MM-dd” print(dateFormatter.date(from: isoDate)!) isoDate = “2016-04-14T10:44:00+0000” dateFormatter.dateFormat = “yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ssZZZ” print(dateFormatter.date(from: isoDate)!) solved Format string to date format swift [closed]

[Solved] How to detect if iPhone is in motion? [closed]

You should look into getting the data from the accelerometer. Here is an example of, how you could retrieve the information. let motionManager = CMMotionManager() if motionManager.isAccelerometerAvailable { let queue = OperationQueue() motionManager.startAccelerometerUpdates(to: queue, withHandler: { data, error in guard let data = data else { return } print(“X = \(data.acceleration.x)”) print(“Y = \(data.acceleration.y)”) print(“Z … Read more

[Solved] How do I get the Lat Long of where the user tapped? in Swift v3 and google maps sdk

I found the solution at: https://developers.google.com/maps/documentation/ios-sdk/events by googling for didTapAtCoordinate, which I somehow knew was part of the SDK. The most important line for me was: mapView.delegate = self. It’s possible that some other solutions I tried would have worked had I used mapView.delegate = self, but nothing else had mentioned it. Also, the func … Read more

[Solved] How do I implement UITextFieldDelegate [closed]

Your ViewController should be an UITextFieldDelegate. You then set the current ViewController as the delegate of the textField, in this case in viewDidLoad(). Implement textFieldShouldReturn so the textField delegates the return task (textFieldShouldReturn) to the ViewController. In this method call resignFirstResponder, this way the keyboard will disappear. Example: import UIKit class ViewController: UIViewController, UITextFieldDelegate { … Read more

[Solved] Textfield values set to empty when coming back from previous view controller [closed]

When you push back to the origin viewController, It’s better to replace using “push” Segue by “popViewController” method . It’s also good using data consistent strategy. And the reason: You should consider the viewController’s lifecycle. When you push back to the origin viewController, using “push” Segue makes the origin viewController’s “viewDidLoad” method is called again. … Read more

[Solved] How can i convert string to date with some strange format

You can use this function to get date from your string. – (NSDate *) dateFromServerAttributeDateFormat:(NSString *)dateString { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@”yyyy-MM-dd’T’HH:mm:ss.SSS”]; [dateFormatter setLocale:[NSLocale currentLocale]]; if (!dateString.length){ return nil; } else return [dateFormatter dateFromString:dateString]; } in swift func dateFromServerString(dateString:String) -> NSDate { let dateFormater = NSDateFormatter() dateFormater.dateFormat = “yyyy-MM-dd’T’HH:mm:ss.SSS” dateFormater.locale = NSLocale.currentLocale() … Read more

[Solved] How can I substring this string?

Swift’s substring is complicated: let str = “12:345” if let range = str.range(of: “:”) { let startIndex = str.index(range.lowerBound, offsetBy: 1) let endIndex = str.index(startIndex, offsetBy: 2) print(str[startIndex..<endIndex]) } 2 solved How can I substring this string?

[Solved] Upgrade Xcode 7.3.1 Project to Xcode 8.0

The final answer of above question is: add the code snippet in your podfile post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings[‘SWIFT_VERSION’] = ‘3.0’ end end end then check swift legacy in build settings and set it to NO for swift 3 or you can set Yes for swift 2.3 (if you are … Read more