Post

Replies

Boosts

Views

Activity

How to handle 12 hours Format?
Hi,My Code to get Local Time From UTC:func getLocalTimeFromUTC(dateString: String) -> (String,String){ let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" dateFormatter.timeZone = TimeZone(abbreviation: "UTC") let dt = dateFormatter.date(from: dateString) dateFormatter.timeZone = TimeZone.current dateFormatter.dateFormat = "dd/MM/yyyy HH:mm:ss" let finalDate = dateFormatter.string(from: dt!) let finalDateArr = finalDate.components(separatedBy: " ") return (finalDateArr[0] , finalDateArr[1]) }If the time format is 24 hours in my iPhone, no problem in the above code.But when i change the time format from 24 hours to 12 hours in my iPhone, dt is nil.How to handle this?
1
0
1.2k
Jan ’20
How to remove the extra white space?
Hi,My Code SnippetmyTextView.heightAnchor.constraint(greaterThanOrEqualToConstant: 20).isActive = truelet myHTMLString =" some html text" myTextView.attributedText = myHTMLString.htmlToAttributedStringextension String { var htmlToAttributedString: NSAttributedString? { guard let data = data(using: .utf8) else { return NSAttributedString() } do { return try NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding:String.Encoding.utf8.rawValue], documentAttributes: nil) } catch { return NSAttributedString() } } var htmlToString: String { return htmlToAttributedString?.string ?? "" } }HTMLString converted to attributed string.But,extra lines of white spaces exists in myTextView at the bottom.What is the reason?How to recitify it?Thanks In Advance
3
0
2k
Feb ’20
Text like PlaceHolder
Hi I have a textField to provide Date for Birth(Requirement). Initially the textField should have the text "DD MM YYYY" . And if I key in the date of birth, need to remove characters (DD MM YYYY) one by one. Scenario: DD MM YYYY is the text displayed in TextField initially. After typing first digit(for example 3), it should be like " 3D MM YYYY " After typing second digit(for example 1, it should be like " 31 MM YYYY " After typing third digit(for example 0, it should be like " 31 0M YYYY " After typing fourth digit(for example 8, it should be like " 31 08 YYYY " and so on.... Is this possible?
3
0
1.5k
Aug ’21