1 00:00:02,810 --> 00:00:09,110 So well come back again in business and we're going to talk about the strings in a swift quote initialise 2 00:00:09,170 --> 00:00:14,290 them how we could append them to each other how we could modify them so on and so forth is going to 3 00:00:14,300 --> 00:00:16,180 be one to our easier lessons. 4 00:00:16,280 --> 00:00:18,090 So let's get us started. 5 00:00:18,110 --> 00:00:19,230 I'm going to go to school. 6 00:00:19,250 --> 00:00:25,030 I'm going to start a new art maybe a playground just so that you know we alternate them. 7 00:00:25,100 --> 00:00:31,770 I think the last one was in our last home with a command line so there's three things. 8 00:00:31,790 --> 00:00:32,470 Playground 9 00:00:35,010 --> 00:00:36,420 so and right off the bat. 10 00:00:36,420 --> 00:00:42,180 We have on a string which really you know helps us faith in understanding that everything is you know 11 00:00:42,270 --> 00:00:44,050 as we would expect it. 12 00:00:44,310 --> 00:00:51,090 Our string of that type of string explicitly told the compiler is going to be a string. 13 00:00:51,180 --> 00:00:57,480 The one thing that we have an s in swift compared to Objective-C is a multi-line a string. 14 00:00:57,630 --> 00:01:00,740 So I could say multi line a string. 15 00:01:00,780 --> 00:01:07,350 They gain the type of string that's going to be I'm going to add three quotation marks and then between 16 00:01:07,350 --> 00:01:16,400 these I can write whatever I want to write like this is line 1 1 and this is a line 2. 17 00:01:16,620 --> 00:01:18,030 And so on and so forth. 18 00:01:18,030 --> 00:01:24,570 So if you have a long line of string on like what's behind the objective see that you had to actually 19 00:01:24,890 --> 00:01:28,170 add for the slashes and ends for returns. 20 00:01:28,290 --> 00:01:34,730 You can just simply add them between three quotation marks which really simplifies a lot of our work. 21 00:01:34,740 --> 00:01:40,980 Now these things are leaderless which are like this can be initialized either this way or I could say 22 00:01:41,520 --> 00:01:44,350 verify my ascii are again of the type. 23 00:01:44,360 --> 00:01:47,120 The string is going to be empty. 24 00:01:47,340 --> 00:01:49,950 All I could say there are there. 25 00:01:49,970 --> 00:01:57,120 The art is going to be a string and that's essentially initialising good as a string without any content 26 00:01:57,290 --> 00:01:59,860 essentially being an empty one. 27 00:01:59,860 --> 00:02:06,520 Another thing that is kind of Nuwan also interesting in swift is that you can actually concatenate the 28 00:02:06,540 --> 00:02:11,820 strings or you can append them to each other just using the operators. 29 00:02:11,840 --> 00:02:19,380 So I could go ahead and say there are let's call it first a C R and that's going to be hello and then 30 00:02:19,380 --> 00:02:26,290 I'm going to have r r let's call it second the C R and that's going to be a space war. 31 00:02:26,760 --> 00:02:35,010 And then I could say where the rest are just going to be first the string plus Second the string and 32 00:02:35,010 --> 00:02:38,600 then if I go ahead and say print on a string. 33 00:02:38,880 --> 00:02:42,550 Obviously Arvi should expect to see Hello space walk 34 00:02:45,690 --> 00:02:51,690 and you know we got art in the compiler and it was in the consummately of hello world which is really 35 00:02:52,170 --> 00:02:59,970 a lot easier than doing what we would do in Objective C because first the our hand a string and then 36 00:02:59,970 --> 00:03:06,830 have the other one second a C R and then close it with a square brackets. 37 00:03:07,020 --> 00:03:12,480 As things are obviously a much broader topic and I'm going to show you a few more things. 38 00:03:12,540 --> 00:03:15,010 One of them is comparing strings. 39 00:03:15,030 --> 00:03:24,090 So in the past you have to use things such as If one string is equal to another string and that's you 40 00:03:24,080 --> 00:03:27,090 know would essentially call a function. 41 00:03:27,090 --> 00:03:33,180 And then we had to you know get a boolean value from that in see if we do this thing a lot easier we 42 00:03:33,180 --> 00:03:41,310 can simply say if the first the string is second string and that's about that I can just go ahead and 43 00:03:41,310 --> 00:03:49,250 say print the same math for instance else I could say prints are not the same. 44 00:03:49,350 --> 00:03:53,060 So comparing a string is a lot easier or instructive as well. 45 00:03:53,060 --> 00:03:54,490 So let's read on this. 46 00:03:54,520 --> 00:03:56,220 We should see the not the same. 47 00:03:56,280 --> 00:03:57,340 Perfect. 48 00:03:57,420 --> 00:04:02,740 And one last thing I want to show you is going to lead. 49 00:04:02,840 --> 00:04:08,890 First thing I think we saw this when we were working in the contour floors and the work and therefore 50 00:04:08,890 --> 00:04:09,710 loops. 51 00:04:09,710 --> 00:04:17,640 I'm harder than I say let my longest string to be a string of course answers. 52 00:04:17,680 --> 00:04:18,500 Hello. 53 00:04:18,540 --> 00:04:20,130 Hello. 54 00:04:20,490 --> 00:04:33,860 This is Iowas both Khyam and now I can't say for any ideas of the type character in my long string. 55 00:04:34,050 --> 00:04:37,920 I can go ahead and say print in for instance. 56 00:04:37,920 --> 00:04:43,980 So that would essentially go through every letter of the character for me which in here every letter 57 00:04:43,980 --> 00:04:44,570 of the string. 58 00:04:44,570 --> 00:04:49,010 Sorry it says escheat double or comma a space. 59 00:04:49,140 --> 00:04:50,850 So on and so forth. 60 00:04:51,150 --> 00:04:53,880 There's a lot more that you know we can do with the strings. 61 00:04:53,880 --> 00:04:55,880 I think this covers the basics of it. 62 00:04:55,920 --> 00:05:02,970 Initialising then concatenating them as well as you know removing pieces from them you can just rewrite 63 00:05:02,970 --> 00:05:09,760 the pieces back to each other and of course comparing them against each other or going through a character 64 00:05:09,860 --> 00:05:12,760 is the first thing that could be useful from time to time. 65 00:05:12,990 --> 00:05:15,340 I haven't the link with this lesson. 66 00:05:15,340 --> 00:05:16,400 I was really a commander. 67 00:05:16,410 --> 00:05:17,740 You guys have a look at it. 68 00:05:17,880 --> 00:05:23,850 There are things such as getting a substring reading only a range of characters. 69 00:05:23,850 --> 00:05:29,520 The reason I'm not going to do it is because we haven't seen those meters yet such as you know finding 70 00:05:29,600 --> 00:05:30,490 Oranje. 71 00:05:30,690 --> 00:05:34,650 But I would recommend that you guys have a quick read through it so at least you know these things are 72 00:05:34,650 --> 00:05:35,380 possible. 73 00:05:35,400 --> 00:05:41,370 And then down the track when we get to know how to use them they want to be completely new topics for 74 00:05:41,370 --> 00:05:41,800 you. 75 00:05:42,030 --> 00:05:44,050 So with that in mind let's move on.