[Solved] Compare two date – Swift

You can convert the string to date using a dateFormatter then compare with the current date using an if statement import Foundation //convert string to date let dateFormatter = DateFormatter() dateFormatter.dateFormat = “yyyy-MM-dd” let myDate = dateFormatter.date(from: “2019-11-02”) //convert today’s date in the same formate let currentFormatter = DateFormatter() currentFormatter.dateStyle = .short currentFormatter.dateFormat = “yyyy-MM-dd” … Read more

[Solved] Swift get from string array

How about dateArray[4], seems straightforward to me. Array indexes are 0-based in Swift. You could declare a function like so: extension Array { func getElement(position: Int) -> Element { guard self.count > 0, position > 0, position <= self.count else { fatalError(“Error”) } return self[position – 1] } } And you could use it like … Read more

[Solved] How can i convert this code to swift 4? [closed]

UILocalNotification is deprecated. Try this code: let gregCalrendar = Calendar(identifier: .gregorian) var dateComponent = gregCalrendar.dateComponents([.year, .month, .day, .hour, .minute], from: Date()) dateComponent.year = 2012 dateComponent.month = 9 dateComponent.day = 28 dateComponent.hour = 16 dateComponent.minute = 11 let dd = UIDatePicker() dd.setDate(gregCalrendar.date(from: dateComponent)!, animated: true) let content = UNMutableNotificationContent() content.title = “UMUT CAN ALPARSLAN” let trigger … Read more

[Solved] Convert a swift function in objective-c

I think you want to find if given string contains at least one of the strings contained in the array to ban abusive words – (BOOL) checkIfOfStringOfArray: (NSArray *) array inString: (NSString *) string { for (NSString * element in array) { if ([string containsString: element]) return YES; } return NO; } Call like: BOOL … Read more

[Solved] Fahrenheit to Celsius convert and printing problem [duplicate]

You need to use String interpolation, otherwise it’s just text. Replace c with \(c) to actually get the value of variable c value. Also f with \(f) for the same reason. var conversion = “\(f) degrees Fahrenheit = \(c) degrees Celsius” 5 solved Fahrenheit to Celsius convert and printing problem [duplicate]

[Solved] Calling viewDidLoad in UITextField [closed]

Call generateDummyTransactions() from sendButton’s IBAction method and then fetch the textField’s text there, i.e. class VC: UIViewController { @IBOutlet weak var providerForm: UITextField! @IBAction func onTapSendButton(_ sender: UIButton) { self.generateDummyTransactions() } func generateDummyTransactions() { if let text = self.providerForm.text { //use text here… } } } solved Calling viewDidLoad in UITextField [closed]

[Solved] NSURL convert mistake in Swift

If you want to display the content present in your URL after we hit your URL in browser, we can do the following let url = NSURL(string: “http://atakaractakip.co.nf/atakdeneme.txt”)! let data = NSData(contentsOfURL: url) if data != nil { if let content = String(data: data!, encoding: NSUTF8StringEncoding) { //It will display Onay AKPINAR as this is … Read more