Operations on string and characters in Swift
A free video tutorial from Educativo Courses
Your way to IT professional
4.0 instructor rating • 12 courses • 22,289 students
Learn more from the full courseSwift from scratch - learn programming on iOS
Learn the basics of new language! Create fast, safe and interactive apps with no programming experience!
01:28:35 of on-demand video • Updated
- The Swift syntax
- Basic programming techniques and constructions
- Key elements of the language
- Work in Xcode
- Build your first application using Swift
English [Auto] Now let's move on to character variables and character strings. We already know how to declare character type variables and constants. Now let's see how to use them. Adding strings to each other and mixing strings with characters is very simple and swift for this purpose. We need to use the addition operator Plus we can also iterate over any string of characters by using a simple for in loop we'll deal with loops in detail later in the course. In the next example we see a bit more complex formatting of a character string. It makes it possible to combine the values of variables and literal characters into a single coherent whole. If you programmed earlier in Objective C you'll probably be glad that in operations on characters it's very easy to use the methods offered by the string class. All we need to do is important the foundation library and all the string methods are available in our example. We show how to use the path component's method if we want to use a string constant or variable and swerved. We can do it in a very simple way by. In a way reversing the assignment and string first equals path elements bracket's zero brackets.