[Solved] Replace string between characters in swift

[ad_1] A simple regular expression: let sentence = “This is \”table\”. There is an \”apple\” on the \”table\”” let pattern = “\”[^\”]+\”” //everything between ” and ” let replacement = “____” let newSentence = sentence.replacingOccurrences( of: pattern, with: replacement, options: .regularExpression ) print(newSentence) // This is ____. There is an ____ on the ____ If … Read more

[Solved] trimmingCharacters not work on iOS 10.3 Xcode8.3

[ad_1] From the documentation: A new string made by removing from both ends of the receiver characters contained in set. It does not remove characters within the string. You can replace whitespaces – corresponding to the .whitespaces character set – in the string with regular expression: let _searchStr = searchStr.replacingOccurrences(of: “\\s”, with: “”, options: .regularExpression) … Read more

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

[ad_1] 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() { … Read more

[Solved] Cannot convert value of type ‘NSMutableArray’ to expected argument type ‘[Any]!’

[ad_1] There’s no reason to be using NSMutableArray here. Just use native Swift data types: let data = [“1”, “2”, “3”] self.personDownPicker = DownPicker(textField: self.servicioTextField, withData: data as NSMutableArray) [ad_2] solved Cannot convert value of type ‘NSMutableArray’ to expected argument type ‘[Any]!’

[Solved] UIButton set titleLabel setValue(newLabel, forKeyPath: “titleLabel”)

[ad_1] You should use setTitle method to set button title for states. button.setTitle(“Your button title here”, for: .normal) setValue(_:forKeyPath:) is a method from NSObject class which UIButton is a subclass of. It is not recommended to use KVO. Read this thread for more information. 5 [ad_2] solved UIButton set titleLabel setValue(newLabel, forKeyPath: “titleLabel”)

[Solved] Why use an extra let statement here? [duplicate]

[ad_1] The if-let construction is sort of superfluous in a simple case like this, but in a more complicated piece of code it can be useful. You can use it in a lot of the same ways you’d use an assignment in a conditional in (Obj)C (remember if (self = [super init])). For example, if … Read more

[Solved] Have a collision only detected once

[ad_1] Yep – this happens. The way to handle it (you can’t get sprite-kit to NOT call didBegin multiple times in some circumstances) is to make sure that your contact code accommodates this and that handling the contract multiple times does not cause a problem (such as adding to the score multiple times, removing multiple … Read more

[Solved] how i can concatenate two variable it type Text Field?

[ad_1] I couldn’t get what you want. Is this what you want to achieve? answerScreen.text = valueOne.text! + valueTwo.text! String values can be added together (or concatenated) with the addition operator (+) to create a new String value: Check here for more details 4 [ad_2] solved how i can concatenate two variable it type Text … Read more

[Solved] Does dateFromServer return the current Timezone of the person?

[ad_1] LastCommunicationDate is a string, but you are converting it to a Double. Try this instead: let lastCommunicationDate = “2022-01-21T10:58:21.367” //Create dateformatter to convert string to Date let isoDateFormatter = ISO8601DateFormatter() isoDateFormatter.formatOptions = [ .withFullDate, .withTime, .withColonSeparatorInTime, .withFractionalSeconds ] let isoDateFormatter2 = ISO8601DateFormatter() isoDateFormatter2.formatOptions = [ .withFullDate, .withTime, .withColonSeparatorInTime ] let date = isoDateFormatter.date(from: lastCommunicationDate) … Read more