[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

[Solved] Ambiguous use of subscript compiler error

You need to tell compiler the type of item, so instead of casting info array to [AnyObject] type cast it to [[String:Any]]. if let imagesArray = info as? [[String:Any]] { for item in imagesArray { if let image = item[UIImagePickerControllerOriginalImage] as? UIImage { //Access image instance } } } 6 solved Ambiguous use of subscript … Read more

[Solved] cannot convert AnyHashable in swift 3

type conversion do like func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { print(“received a notification”) Branch.getInstance().handlePushNotification(launchOptions) } for more information you can get from branch in Git solved cannot convert AnyHashable in swift 3

[Solved] Expected type after as

as? is use to cast one type to another, you are asking Xcode to cast response to another type, but haven’t told it what to cast it to. As the error says, its expecting to see a type after the keyword as 2 solved Expected type after as

[Solved] Swift 3 custom touch motion to trigger action [closed]

Well you question is divided into 2 parts and I’ll answer them both. 1- What you are looking for is UIGestureRecognizer where it’ll recognize a gesture and do an action accordingly. Here is a link taht will help you out! https://www.raywenderlich.com/76020/using-uigesturerecognizer-with-swift-tutorial 2- Unlocking the phone is impossible without jailbreak. Your gestures are bound to your … Read more

[Solved] Is there any way to making transition without storyboard?

I solve my problem. I just add that code for calling animation transition in my homecontroller: extension HomeController: UIViewControllerTransitioningDelegate { func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { return faceanim() } func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { return faceanim() } } And to button action is: @objc func handleAccount() { let … Read more