Display a text word by word slowly in swift

split word from string swift
swift split string
swift string
ios swift capitalize first letter of string
swift substring
swift 5 string first letter
swift regex
swift get first character of string

swift 5 iOS 13

Trying to print out a sentence word by word slowly. Drafted this code that works, but I fear I am going to crash the phone with too many threads if I feed in a sentence that is too long.

    let textFeed = "Some text message made up of words"
    var second = 1
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {

      for word in textFeed.components(separatedBy: " ") {
        var delay = DispatchTimeInterval.seconds(second)
        DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: {
          self.infoText2.text = String(word)

        second = second + 1

Any thoughts on doing this differently, less threads?

a simple rekusive func

printMessage(message: "I am a test")

func printMessage(message: String?, delay: TimeInterval = 1) {
        let splits = message?.split(separator: " ", maxSplits: 1)
        DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: {[weak self] in
            guard splits?.count == 2 else {
            self?.printMessage(message: String(splits?.last ?? ""))

Strings - free Swift 5.1 example code, How to check whether a string contains any words from an array While this is really important to display text, it can also cause havoc while trying to all the characters in the string this way you could accidentally create extremely slow code. Microsoft Word uses template files to create documents. Normal.dot is the global template file that Word uses for creating a blank document file. This essentially means, the template file is always in use when Word is in use. Word also stores all style related settings, such as font size and font type in this template.

i have this piece of code

extension String {
var characterArray: [Character]{
    var characterArray = [Character]()
    for character in self {
    return characterArray

extension UITextView {
func typeOn(string: String) {
    let characterArray = string.characterArray
    var characterIndex = 0
    Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { (timer) in
        characterIndex += 1
        if characterIndex == characterArray.count {

// and in your view controller you just call it like this 

override func viewDidLoad() {
    let msg:String = "test"
    youtextView.typeOn(string: msg)

Reading from disk: contentsOf, The start.txt file contains over 12,000 eight-letter words we can use for our game, elements they contain, so reading count == 0 can be significantly slower than� If typing in Microsoft Word is very slow even though the system's resources are free, you may have other problems on your hands. Find out about typing in Microsoft Word when it is very slow even

Based on the answer given by Was'Siim Ben Hssen, only this one uses a UILabel.

let textFeed = "print out words one by one slowly"

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
    let words = textFeed.components(separatedBy: " ")
    var i = 0
    Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { (timer) in
          self.infoText2.text = String(words[i])
          self.infoText.text = self.infoText.text! + String(words[i]) + " "
          if i == words.count - 1 {
          } else {
            i = i + 1

Change these two lines to get a character by character reveal.

//        let words = textFeed.components(separatedBy: " ")
          let words = Array(textFeed)
//        self.infoText.text = self.infoText.text! + String(words[i]) + " "
          self.infoText.text = self.infoText.text! + String(words[i])

Achieving a Type-On Text Effect in Swift, acting, text in video games would type onto the screen. This gave a speech affect to the text by simulating the time it takes to speak words by� Slowly Total Number of words made out of Slowly = 23 Slowly is an acceptable word in Scrabble with 12 points. Slowly is an accepted word in Word with Friends having 13 points. Slowly is a 6 letter medium Word starting with S and ending with Y. Below are Total 23 words made out of this word. 5 letter Words made out of slowly. 1). yowls 2). lowly

Building a Text to Speech App Using AVSpeechSynthesizer, This Swift programming tutorial will show you how to build a text-to-speech spoken word by changing its foreground (text) color from black to orange. I just Updated my xcode to 7.2 and now the voice speaks really slowly. Programs need text components for tasks ranging from the straightforward (enter a word and press Enter) to the complex (display and edit styled text with embedded images in an Asian language). Swing provides six text components, along with supporting classes and interfaces that meet even the most complex text requirements.

swift, Display a text word by word slowly in swift. swift 5 iOS 13 Trying to print out a sentence word by word slowly. Drafted this code that works, but I fear I am going to� The standard text display interface object for big chunks of text (i.e. scrollable) is UITextView. You can write your text as HTML, just as you are doing now, and convert it to an NSAttributedString for display in the UITextView. Or you could store it as an RTF document and, again, convert it to an NSAttributedString.

Create a Text to Speech App With Swift - Code Tuts, With the release of iOS 7, Apple introduced a text to speech API that allows developers to add text to Be sure Xcode displays the ViewController.swift file on the right. The lower the rate, the slower the speech will be. “Life is 10% what happens to us and 90% how we react to it.” – Dennis P. Kimbro “There is no royal road to anything. One thing at a time, all things in succession. That which grows fast, withers as rapidly. That which grows slowly, endures.” – Josiah Gilbert Holland “There is no royal road…

  • check my answer maybe it helps
  • string.characterArray doesn't seem to exist on iOS 13 under swift 5.x.
  • oh sorry i forgot something check the edited answer
  • I would vote this as the accepted answer, but it is based on a textview ultimately and I got a UILabel. I rewrote it and posted a new solution based on it!
  • @user3069232 weird its working for me why its not working for you for ios 13
  • And it works better than my original one did! THANKS Was'Siim!
  • the first solution is working for me why its not for you ? you found the issue ?
  • The first solution launches a new thread for every word as did mine. It had a massive overhead.