What's new in SwiftUI for iOS 14?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Even though I was speaking even faster than usual, I still managed to talk for over an hour! Sorry about that – I get awfully excited during WWDC 😅

👍︎︎ 24 👤︎︎ u/twostraws 📅︎︎ Jun 23 2020 🗫︎ replies

Paul, you’re an amazing human being! Thank you for all that you do for the iOS community.

👍︎︎ 2 👤︎︎ u/pupdogg007 📅︎︎ Jun 23 2020 🗫︎ replies

Thanks so much for this!

👍︎︎ 1 👤︎︎ u/shaundon 📅︎︎ Jun 23 2020 🗫︎ replies
Captions
hey folks so mm z20 has just kicked off with a remarkable keynote sheriff loads of amazing things for iOS 14 Mac OS 11 now watch we're 7 and of course TV OS - there's lots of amazing stuff happening and in this live stream I kind of want to walk through some things I have discovered why I have not in any way mastered this stuff I'm is speaking out like you I'm just throwing code of Xcode trying stuff out refining stuff breaking stuff fixing it again and trying out with a new iOS 14 API for Swift UI and I want to walk through some of the things I've figured out so far I'd love to hear feedback from you things you've tried things you are noodling around with things you want to learn more about let me know I can try and find out for you or I can show you the code here and my goal very much is to show you as much code as I possibly can in one space of time so by all means you want to go ahead and use the YouTube chat area to ask questions about do my best to answer them otherwise I'm going to walk through stuff until I get bored which is me a while away yet I'm on by the way if it cures I'm I'm on Houston time right now like Central Time somewhere there's like 9 p.m. in my head right now and I go ahead and try and share my screen let's see this is gonna work with me in the corner let's find out cool so you can see me and I can see me cool extra cool lots of me everywhere right now so I'm gonna try and let me move me down to the corner like that how's that okay hopefully you can see me you can see the screen and we can go ahead and try out some some code now there is stacks of stuff that changes 50y for iOS 14 I'm gonna walk through a handful of bits of it things that really caught my attention things like grids and lazy stacks and color pickers and so many more things and if you have questions by all means ask away all question already forever from you can use if net yes you now can use if let ah big win I think we have dug Gregor to thank for that on the Swift team I don't know so thanks Doug or whoever it was made if Network and switch caseworkers well super nice also by the way in Swift five three which is in Xcode twelve you get the chance that drops self from so many places which is amazing force with UI code anyway let's crack on with doing multi-line text because nowadays you actually have a real multi-line text control for doing multiply text and press command R to run my basic hello world example to get started I'm using my my magic keyboard for in Apple's keyboard and it's not my regular keyboard so bear with me this could be a bit a bit of fun as I try and figure out how to get the quinoa to work properly it's gonna launch up hopefully here the iPhone 11 Pro Max's simulator let's find out in any time yes if let's which case is what brilliant okay let's hello world boom let's make that into a text view this is all stuff text fields are old stuff we used to say things like at state at state private var text equals hello world and now Ryan doing text here would do text field with that prompt to placeholder and text would be dot text boom and we'd now get a editable text field of like in iOS 12 that is all school stuff but now in iOS I was 13 now in I was 14 there's a new control we can use which is a text editor which looks very very similar or it's a text editor like that there is no placeholder for that so does to text it's a text dollar text and you will get a multi-line text error right now you're seeing YouTube studio ROM screen Paul no check it out I don't share the right screen desktop plus me desktop plus me you're seeing the wrong thing I see why Xcode there we go I just do the whole screen there we go that's much better much better see my screen now right let's make some padding around that's we can see we're doing more easily padding that's what the chat windows for folks that's why it's interactive you got to prompt me and kick me and nudge me I have hello world now I can go ahead and type freely and boom you get multi-line text as you would expect awesome now you can assure you want to you can add a line limit if you want to can do dot line limit if you really want to and today I want no more than five lines if you want to and that actually works that was quite hard to do in the UI kit and it actually works out of the box in UI which is great it is just a regular text by the way so you can customize all you want you could say things like I want a foreground color of blue that's a new Co Commission for you can see sensible defaults out-of-the-box how you get hello twelve and your text completely out of color in blue and you can customize you can say actually I want to use that font dot ooh which we use headline but chunkier all prod Kashkari anything new with property wrappers yes lots of property wrappers have change there are new property wrappers let me know the Chatwin if you want see some cool new property wrappers because there's new property rounder that's cool anyway a larger font that's headline let's try title boom and we'll get a nice large there we go even bigger it's customized well do you like I would say by the way there's a nice new way of doing custom fonts you can actually say I want a custom font that scaled relative to something else that's one down here so I want to have I know georgia size of 24 by default but relative to large title for example so I get some flexibility with it to adapt to that type which is really really nice so now I'll get my georgia font but when i use these controls down here i can say make the font bigger or smaller and it will respect that for a change which is really really nice so yes while it is in previews cuz it's lightning fast because this is Express command all it runs straight away no need to do previews how much coffee zero copy today so far I'm doing very one copy front anyway that is 10 is a really really simple thing to do let's move on let's look at progress for use cuz you can do two types now you do the bar style and takes a long of colors what you can do the indeterminate stuff is of activity indicators spinning wheel thing and the spinning ones brilliant you just said what progress for you progress of you and it'll say great what's your title and I'll say it is loading but in that's it and that's you guys spinning indicates out of the box Roger I want up here on the stream mind you there it is it visible in a stream spinning around happily it's really easy to do those things nowadays which is great puts in this Southside I could try but I'd have to sort of lose this chat window Brian Tolliver sir you have to have big soon you did not have to have big sir it works great inside Catalina anyway so that is there a spinning activity indicator if you wanted to have it one that's attached to some value going across like like bright future ask us and our progress bar is it can be it's both so we could say I want to have private VAR download amount here download amount be equal to zero point zero by default and then it's Miguel how you doing and then rather than having just like loading we could say I want to have a value of the current value download amount and then a total value of a hundred and it basically means go between zero and 100 and it's much nicer than the old zero to one at the old UI progress for you so you can customize that very easily and of course you could say now I want to have a V stack at this Apple keyboard a B stack progress for you and have a button move along please with the action of self themself to download amount I'm still writing Swift five point two is terrible but equals to no point well I'm you can customize that with a button click it is angry for me so I must offer be closing braces here but doom there we go and now I can click along my little bar yeah look at that thing tiny amounts to make many of these things I might make that do perhaps five instead of no point one otherwise you'd be here for very very long time let's try again move along oh yeah beautiful so that's the new progress view it's super simple to do indeterminate and determinant really really easily awesome next up you can do lazy stacks now you can control the way you have stacked or not which is great because in the old code we had a stack here with some users site if I had like for each 0 through hundred ID'd ourself I in if I had text row I then it would load always up front which is you know maybe what you want probably not what you want city for a stack a scroll view it's about a scroll view around this thing here it would be making all those things up front even there only a fraction invisible ah so Miguel no self is not underneath it's amazing that's one of the major changes inside swift 5.3 if you go to the amazing website what's new in swift calm you will see MOSFET enclosures by Blastoise conformance is self longer quiet SEO 269 mmm basically anywhere Britain knows self isn't required can it needed there's no chance of a retained cycle when you're instructed is impossible so just get rid of the self required entirely it's absolutely lovely anyway so that's nice so we can have this thing now we have lots of our rows being crated with a regular V stack they had more these things say you know a thousand of them it's gonna make them more up front which is a lot of work we don't want that necessarily because it's gonna waste a lot of time making all these rows up front right right bad a it Harlan the cool cruising here today I love it keep me going Lance it's making all smoke up front which is it's not necessarily efficient and you can see us in action you could say something like I want to have a struct called sample row which conforms to the view protocol and has an ID integer id integer even int there we go and bar body some view and I'll just do text again was it row backslash ID message ID if we had a custom initializer in here for our struct in it ID int I'll do self dot ID is ID and print loading row ID so I've made this custom sample row straps are basic test for texture right now with a custom row and it's helpful because when it's being made you will see it being made it'll tell you I'm making one two three four five a thousand and so forth we can use that inside up for each down here we could say for h20 two thousand comma content content is sample Rho dot in it make sample rows for every one of these things and I'm still using a regular V stack here so when I run this code back we're gonna see a thousand rows being made 1,001 Road being made boom upfront and it always was doing that right that hasn't changed it's meant go ahead and make a thousand and one rows as soon as the app launches which is not a good idea particularly if they have content inside that's not just plain old text you had to have images or whatever yeah not so good fortunately now we can say actually I want to have a lazy B stack here lazy V stack and the word lazy in front super-easy and press command R again and look at the difference in the output it's now loaded rows 1 through 0 through 41 so only the ones can actually see down to the bottom of the screen as I scroll down further you see it below there it's popping through it loads them all dynamically just really really nice much better way of working but I would say is when gets to the bottom it'll load all the rows I go back again nothing else is being printed out it makes the struts once and keeps me around now my understanding is it'll release the underlying UI views or NS views to free the RAM so y'all keep me around huge pictures or whatever but the actual underlying struts will be kept around once they've been created which makes sense another thing which I don't think they mentioned the stage was a bit of a surprises one you all look really carefully for this if I go back to a regular V stack regular v stack again and scroll around you might notice on this the scroll bar is right next to the rows it's over here right next to the rows so it takes up only amount of space required to fill that thing if I click on the outside space here nothing happens I can't scroll around here whereas if I go to a new lazy B stack and try again you're gonna see the whole thing becomes scrollable so scrollbar now appears on the right-hand side here like that I can grab anywhere and pull it around so the difference is a regular V stack will take up the just enough space for its content knows how big is gonna be a lazy snack presumably has no idea how it's gonna be so it becomes the preferred width of infinity or height infinity and therefore HT tax so it'll fill out all the space it can so becomes flexible and that's why it Scrolls on the right-hand side with a lazy we stack oh okay that is progress views that is V stacks and lazy be stacks and so we have two programs I always give it up take senator I've already right okay next up Maps you can do maps now this is one of the annoyances now and of course the map kit has maps and sprite kit has sprites and so forth and you can amusements with UI now but their documentation scattered around elsewhere so you can't dig around to prime find where it is I've been doing the game on your behalf array Oh Adrian wants property rappers folks if you are property rappers your type property rappers into the chat window now you've got ten seconds otherwise I'm gonna do maps I like maps that's a good we're doing lots of maps now make your mind up Adrian you could choose folks this is your stream I'll do any part of iris 14 you like it it's noodle around it's great fun go ahead and vote in the chat window if you want property rappers or Maps MPA there's not an option click baking alright it's like spray it cause it was a map so property rappers all right maps and probably rappers yeah will do both don't worry I'm not going anywhere it's only twenty five 10+9 here for me all right let's do maps maps surprisingly simple I haven't quite cracked all of them yet you can go ahead and say first obviously import mapkit that's where it comes from import mapkit boom you have to tell swift UI what to draw for the screen and this is not just position a center but also the the size the draw the span of the map to draw so inside here we could say I want to have a private VAR region how much of a screen is that is the map and how much mapping drawn and where it's being drawn a coordinate for the thing and this is a particular type called MK oops M equals MK cordoned the region one of these things here and this thing combines that long and also under the chat window can't quite see the code completion it combines lat/long but also a spam so let us try that initializer there put the chat window back back and see maps with property rappers yeah I've been as I do so now we can say give me a sensor I'm gonna do a CL location corner to D they say latitude longitude it's anyone know any good lat/longs off top of their head if not I would give all one London Wicky yes let's get good last year longest huge boom okay ere is the that's it on zebra London I say good but it you have to do uh that's latitude and let's paste that into longitude boom okay so that is where we want that the sense of the map to be the next one is a span yo Joe in asks for WebKit I'm afraid map it's not in Swift you I still and enough he'll be landing in this release perhaps iOS 15 a coordinates pan is an MK coordinates pan and this thing takes a lat Delta and long Delta how much all these screen should be shown so as you pinch in zoom it'll draw it in a different size and so forth so I'm gonna do no point five and 0.5 so degrees that I specified into a tiny bit of space that is the region we want to show in the map and once you've done that it becomes trivial work really really easy cuz there's a map initializer map it's just called map I love it with a coordinate region boom and you just say it's a binding you save dollar region that's the region I want to show I'm using the binding here dollar form because as we moving around the map I want that Center to update as you pinch to zoom I want the span to update and similar Casper why it's not through a.m. for you Paul not in the UK it is 3 a.m. for my family sing sleeping in to sell out the door I have moved my brain to Houston time because obviously BB C's happening so be in the UK it's not a good time zone anyway I can now pinches you around it's a regular map which is great that beautiful so as maps real easy next up colors you can do car Pickers now this has been a request for developers for as long as I could possibly remember this and remote image views and sadly one out of two ain't bad we get remote imaging now we can you get colors now you don't get a road you so we get colors now we can do color pickers using a built-in system color dropper thing which is very very nice I'm not sure it's fully refined yet but it is very nice and actually if you listen to Josh at the State of the Union he said something fascinating which was that the uikit color picker was built using this with UI color picker so it uses the color picker from Swift UI brilliant as a little nugget of information isn't it anyway color Pickers you can now say I want to have a color be equal to color got white for example color got white and then here use color picker color picker like that I don't want the title and a selection that's it it really made it brilliantly simple well done bit color and by default you will get a pasty support you can't you want to disable that County you so I'll just do dollar color color and then map kit still uses UI kit right I don't know Muse map kit I've no idea will actual use it underneath anyway that's one huge color picker I was pressing it and you got a color picker UI we can sort of selecting colors change your pasty you can go to a spectrum mode and take around you want to and the slightest red green and blue sliders and it even has display p3 lovely look at that so it's a very flexible color picker it's even this little dropper icon up here so you can say I want to find you know this exact thing that one for example so for a for a first stab at a color picker that's very impressive so yeah well done Apple for doing that about time ad frame width height only it's of course to kind of frame yes thank you right that's color Pickers what happened next Oh scrub use you can do scrollviews now so they scroll to a location I mean like huh waiting that quite a while it's always an annoying theme because you might be able to say hey you know move down fifty points and move down to the show this thing whatever and now it works it works brilliantly so we can do that very quickly now I could say what about file browser I don't know what about file browser yes it's not backwards compatible to iOS thirteen this is all iOS fourteen stuff they've made no hum wrapping library to go back for that Oscar Alvarez is there some videos with you I guess there is it's a video at fifty why of course sir is you can snare say in iOS 14 you can say import AV kit and use a new video player video player this thing just takes a player now actually it takes a an overlay she won't be really cool but takes a player as well so the players Navy player which is a very dull and this once a or L so I do have one I made earlier but what was URL this is it something like bitly come on you can do web browser bit dot Lee /sw Swift yeah that one this is my what star will compete us about Swift don't play back and I want to have music on YouTube please no no no no that thing there was a example video but doing streaming it's a bit flaky on the simulator bit works great on devices use a real device for this folks always a lot problem so the URL you'll just do URL with a string of oops that turns out the short one should work to which was something like bit dot Lee go on bit dot Lee /sw Swift don't like that I'm gonna cheaply for some wrap that and that's it you'll get a video player running back like I said it does not work well my simulator you want using an actual device this is running iOS 14 already and it's actually very stable by the way it's y7 indeed anyway slight issue yeah don't you submitted for this it won't work use the use the device it'll work much better and the best bit is you can actually provide an overlay you can say I want to have some content here text hello world and then give this font large title ah frame master on 30 frames do padding and then background colored of black dot opacity no point 8 and that will be overlaid on top of the video player which is great so you can just have the video player with your custom watermark whatever on top it works really really nice which is great so that is video from Oscar Alvarez a special diversion was just fine where were we stacks done lazy stuff done progress for you done maps done color pick it done Oh scrolling scrolling scrolling super cool and iOS 14 thanks to some changes with UI they've really made this much much better so let's get rid of some junk here here is some junk here let's make a scroll view scroll view now it's been the case if you had in like um a B stack here and then had ups B stack even come on I had a button saying scroll to item whatever and you had a little items here like and I want to have like text hello world many many times like this whatever just stuff I ate one of these had you know some concept behind it and we'll do a height of 200 each time so it takes a little bit of space in the screen I'm going to end up with a fairly dull broken scrolling hello world thing enough yes a little bit more than that but it's quite enough let's do a couple more let's add in some more here okay that's much better I might make the V stack be a flexible with dot max-width dot in frame max-width wait look at this thought frame max-width dot infinity boom do that so now get a scoring thing okay now I want to do when I press one of these buttons here I want to scroll on to a particular item I'm asked around to you know show me whatever and that's now possible in 50y for iOS 14 you can say scroll to particular thing and it's done using identifiers you just say dot ID with some kind of identifiable thing hashable object you could say you know hello or show me or you know ID five down to you any that you like inside there and it will automatically scroll to that plate all you'll do is wrap the content inside a new type called a scroll view reader this works much like a geometry reader does it makes a new view we can calculate things inside there to do stuff so that's move all that's inside the scroll view reader hope you look the same or almost the same there we go but now I can say inside my button action I can use value I can do value dot scroll to something in my case I'll use ID five scroll to five and you'll find the ID of the object inside the scroll view and scroll to a position which is great so beyond scroll view and boom there's show me now you see it's a little lazy list on to sort of just make it just about visible so I came to the bottom of the screen there you can customize that if you want to you said I actually want to scroll so that it's in the center or the top whatever one two that's possible you just do scroll to five and go an anchor I'll say anchor Center rohnke top red you want to scroll to that location let's find out it's called whiten boom smack in the center that's it so it's not so much we have to say you know scroll to five hundred that isn't required anymore we just say scroll so this thing is centered or this thing in the top or near the top or whatever you want to connect all to a tag I think it's called IDs as the point of it talent Turnbow you give things IDs and scroll through those things which is much nicer can you elevate a scroll ask Jeremy good question as we find out we find out with animation that let's find out it's exciting and the answer is yes you can oh and I want to play with it can you do like an impatient what animation animation door spring will that work will it overshoe slightly slightly slightly let's find out no oh well no I could do like presume you know animation dot linear with a duration of three seconds I'm just curious now it's noodle around it's great fun but there's not noodling around scroll no it completely ignores your animation so if you didn't like you know repeat forever that's just not what do anything about looks of it so it'll animate but you can't control the animation no that's a great thing for radar not the repeat forever that's a stupid idea but becames rolled on the animation over X seconds is a good thing to radar so some remind me to plant a radar yes Harlan thank you very much the file feedback get this thing fixed because that would be a lovely change to make you know don't just jump there the linear animation it's very dull go there with a easy and ease out haziness detail works perhaps easy and out no adoration you horrible think maybe I'll get slightly nicer let's find out scroll to item that still were nice yes radar remind me later to use radar because it's much nicer anyway so that is scroll you can now scroll to things in iOS 14 which is we're doing ice who want to see some grits or property rappers or sprite kit or something else I don't mind it's your stream folks which has let me know I'm happy to noodle around and and talk at my screen as much as you want in the meantime I think I've earned some chocolate milk this is not sponsored but you know this is the treat to myself and I'm working hard oh we want see grids by looks of it okay I like words too I've been working as you might matter non-stop since 10 a.m. Pacific so I am psyched right now grid right you're see grids fine SD grids with grits I've cheated slightly here because I've actually imported some Jason already this is the complete list of swift UI app SF symbols names of pictures as Jason and I've imported my all-time favorite extension bundle decodable which makes it easy to decode Jason from an app bundle this better you say give me an array of strings from symbols Jason and I met back boom everything so it's real easy way of doing Jason so I'm gonna use that to to do grids I really struggle with Apple keyboard I can't find the keys very easily all right let's do that so grids from Hawaii sweet now I feel extra ballot bear being in the cold wet UK will do let's symbols equals my custom extension bundle dot mein gott decode and this thing takes whatever you want decodes I'll say array of string dot self from the file symbols Jason and I will load all the symbol Jason thing into an array of strings which is fine but what's with you I wants to know is how should it render those things on the screen what is your grid layout what a column layout so we can say I want to have a column layout columns be an array of grid items and if I say I want a grid item here and the sizing that we could say let's use let's use flexible for now just fill the space stretch stretch it out you want to then we can say in our body I ought to have a scroll view and tied there a lazy V grid a grid of stuff will loaded contents what a little more affront and this will tell you at how many columns you have our say that's my columns array and you got some spacing if you want to I'll leave it blank and I'll say for each each of my symbols my string array using ID backslash self symbol in I'm gonna hide this preview pane so it's not missing anything right now symbol in each one of these things are what a V stack using if you want V stack there we go using image cat that on this keyboard system name of symbol and the text of the symbol like that so show the picture and the text side-by-side for every picture in my array of stuff I press come out ah we'll get that by default not bad we can customize that we could say actually I want to have two coms both flexibly size so the hit of much space you want and then maybe wrap this inside a nice navigation view looks a bit nicer in a screen indent one level there we go and then add like a navigation bar title SF symbols browser and just to make it look extra good a little bit of spacing for our symbols and add a comma here so it can pass cleanly of course let's try that but super simple sf symbols browser with like a handful of lines of code let's add a little bit of padding perhaps the edges so doesn't look quite so constricted horizontal even better hopefully yeah okay it's pretty pretty easy now if you've done the uikit code or your collection view you'll recognize this is effectively a improved flow layout this is not compositional collection because you can't do all the beautiful new thorgan or scrolling mmm Steve Farina one hugging you can't do that that is not in here this is the old style clay should be stuffed fractionally improved so - I bet still it flow layout so maybe iOS fifteen perhaps we will find out that's grits well there's a one nice thing which you might appreciate and it's not quite as good as the approach I've taken he says with zero ego whatsoever which is you can now watch change events coming in for state so you could say for example if I have at state private VAR email address equals poor at hacking with Swift comm when you have stuff inside here to do text editing you might say our text field text field with the placeholder of enter your email address text being bound to dollar email address like that is there pull professionist views no there's not I'm afraid not so add a text field started this course to us and our styles text field style of rounded border text field style now what you can do is to say I want to have an unchanged event so you can say unchanged of the name or email address or whatever field you're working with give me the new value coming in and print out that the email address was changed to email address boom like that and now as you are writing stuff it will call that again again again telling you what it was changed to so you can see down here it's changing changing all the time so you can catch changes freely which is really really nice that's not the way I did it beforehand if you look at the source code for control room which is a really nice simulator control system you can snag my own change from there I think actually mine is a little bit better because I extend binding no it won't be in there we go so I actually extend binding directly so you can you can have a binding actually with antenna inside it so that the course will handle it directly so if I put it into the code it's a different straight away if I have in here you can say down here when you have some binding inside here you might say email address dot on change do something and it means you can perform wherever you want to in here that's a nicer way of working I think then having it caching all in modifiers oh well it's their their choice not mine so I don't have to decide that's how it's working for you you hope you get a triplet string suit you I says Romi yeah no no I think it's never gonna happen um I actually asked had seen that in the labs last year and they're adamant that attributed strings weren't a good idea so I'm afraid that's unlikely to happen so know what else we have Oh user defaults this is one of the new property wrappers you some folks last property wrappers blind minor text you can do a new property rapper called app storage which will read and write from user defaults smoothly it's really really nice I'll showed you now the house of milk hmm powered by chocolate milk forget forget coffee overrated if we had in here a button saying oh login and we want to change some value here we were working you might say at app storage give this thing a key and say I want to work with email address like that VAR email address is Paul that hacking with Swift calm and we can do is that thing is bound to use it false so I like any changes here to like you know self-taught email address equals anonymous Apple calm it'll write that user default automatically like at this in like a V stack and then show the usernames well as let login button text off email address boom make it slightly larger so you can see on the stream but title so now we should hopefully see Paul at hacking whispers comm boom I press login the other common and honest apple.com so what's doing is it's it's changing this thing here the property which will write it to user defaults and Riaan voc's the body property for our view to reflect the latest changes from user defaults and even better that thing app storage works even without the property rapper doing the right if you had had a regular you know elsewhere in your application anywhere an application so in like user defaults dot standard dot set ah Harlan at Haskins comma think of longhand I'm porky email address that's not his really murder I stopped emailing please email address that would also work because it would detect the change anyway actually attaches an a kvo watcher to user defaults so it'll attack the change and reload the view automatically which is very very nice super tough my dogs thank you so much it is for the dogs it is half past three in the morning so they are very very much asleep downstairs and even though they might come for treats I suspect they would be keen to sleep some more anyway that's one of the new property up is an iOS 14 to swift UI apps or just really really nice and there are more there's there a scaled metric scaled metric is a way to do UI font metrics basically wrapping it up nicely if we had to in like at scaled metric var image size is a CG float people two hundred and down here I could say I want a rectangle I'll do a frame frame width of come on Hudson to tie proper rhythm this width of image size this keyboard height of height of image size I resize image size boom it will use that to render the rectangle but because it's using a scaled metric it will understand as you use font size changes to get large or smaller so it matches other things around it which is kind what you want inside a good modern app it's not awesome key what is this Apple keyboard look like that's all my you keyboard is actually my laptop is just there out of shop because the fans come on so loud code so I've put out a shot a little cooling mat missus in the corner a wall of shame right now and my regular keyboard over here that is really clicking as you can hear it's super clicking its own mechanical keyboard and I wouldn't want to play you with that sound anyway but angle is now that size and all being well if I move is over here to hide now I can't on the chat window and over there like that it should scale according to my settings let's find out yeah that so the rectangle change size depending on the user's this is about the settings and they want extra large small ever you want to which is great because now you can say this should be a fixed size relative to the things around it if that text is drawn bigger make the rectangle bigger or the picture bigger whatever you want to bigger around it so the whole thing scales uniformly which is really really nice and in fact you can even say I believe this should be relative to a direct type size like title whatever you want to and it'll scale relative to that font size growing or shrinking so it really match the things around it but absolutely flawlessly which is nice so that is one of the new another one of the new property rappers cuz that's that an app storage are really really nice what else do we have is there a search bar yet no I have not seen a search bar yet we are still missing search bars a shame and visual effect views can't get them all oh great question from say Hodge see what service being state object and observable object that's another new property rap a state object state object looks so this mistake many folks have made now I've made it too it's completely normal to make if you had class customer has a name string and VAR is annoyed bull this thing might be an observable object which is great that means you can watch it from your views pass around as environment objects and wherever you want to and if I'll just do default values here of Taylor and false cuz she's lovely she wouldn't be angry with she you can pass around environment you can pass a view to view to view that's what the herbal objects do the problem is that swift dui's views can be recreated whenever they want to be they him destroyed and recreated destroyed recreated a thousand times and we shouldn't care and so if I had some code in here saying her at observable object of our customer equals customer I'm saying create that customer inside the content of view and let that content if you manage it so I put in here to make my code compile or observed objects sorry yeah I do that ten times a day context of customer doesn't name we're saying create that object a reference type and owned make owned by the content view and that would work most of the time and that's the frustrating thing most times it would just work sometimes some random times when we load the view some changes like that going from screen to screen perhaps it would be destroyed that we create content view would recreate the observable object behind the scenes we don't want that and so they've added a fix for this called state object a new property wrapper specifically to solve this when you want to create an external reference type like customer inside a swift UI view or window oh no and whatever you want to do of stuff it will now own that safely which is what we want so it's a better way to do ownership or reference types so you now want to use at State when you have local private state being crated locally and at state object when you have reference type data being created locally you can then pass it off of course you can using environment or using you know as properties to other views but the thing that crates initially has to have at state object and it's particularly important because in Swift UI now there's no delicate so there's no more apt that here at class you can create things and safely and forget about them now it's all struts all the way down it's Turtles all the way down right and so we've got to have this new state object type in there to track that information for us so at a third new property wrapper right there's its proper physical all right now it's just great when two state object versus when T's observe object you want to stay object if the view or the window every struts making it is the thing that's making it so in my case content view is making the customers object it is owning it as a source of truth right there it owns it pass it around everywhere else that refers to that thing we'll use that observable object so the thing that creates it at set object everywhere else observable object yes Zach app delegate seem to look at Bank bank gone all nice and cleaned up which is a big improvement quite frankly what else sprite kit noise and sprite kit like it's fun does require a bit of hacks soaring as you'll see but it's it's fun it works it makes my MacBook gets super fan hot heavy it does like spin another fan sprite kit you don't understand different still look I can't be any simple on this the thing that makes the reference type has a property the thing that says blah blah equals the type has to use at state object everything else will use at observable object that's that's it that's all the rules mark my kins how I change starting view right here you just say I don't want content view I want a big mountain in big-mountain studio view boom like that I have not one of those sadly you get the idea that will make a new view for launch it's much much nicer and it's brilliant because with core data there are some brilliant rest conditions if you want to get your persisting container which is an asynchronous call can load it you'd say load it and inject into the environment and iOS would correctly wait for that to compare the lobe for making it available to some managed object context and Mac OS wouldn't Mac OS just hard crash saying there is no object context black every time it was great so now it's all struct base it's gonna work ways yeah so yeah it's much much much nicer Brian Oliver will it be an updated holidays 52 I yes there will be but the changes are fairly small so I wouldn't worry too much what else they pick her out of this changes it for first you I I'm not sure how's it changed nitrate over in UI kit but not sure I said do I window group is the way of handling I'd leave Windows and Mac OS or a protocol handles scenes on iPad OS I expect is there pull to refresh functionality now no not that I've seen sadly you get I did cut back it earlier you might have come to you late for that to rewind it was lightning fast I was like gosh I've already been talking for almost an hour despite the extraordinary speed I'm going at metal point shaders I have no idea did Maps already Brandon sorry at the rewind get the maps and they also should do sprite kit well Jeffrey Masson good question where do you initially inject an environment object now so you do it here so in this case this is a way it's saying make the thing you'd say what my customer to be inside my app here once and then inject it at this point it's cell they have an environment object here or whatever and that's what we do instead customer that's we inject it or do it you know in a property initialize whatever you want to down to you other improvements to navbar title lab are items there is a change to navbar title and I saw flyby I have not investigated too closely that's let's try to have together shall we so in that navigation view well there's one thing on Mac OS we now do a subtitle but not on iOS so yeah sucks you can now I believe say what is on Mac OS Navi gay hello the G Keys really bad let's keep what I was the first version was the rats and - hello sorry hello world so I believe there is now a new modifier to do navigation bar style yeah you can now say it should it be inline or or big as a style rather than attach the text of the navigation bar title directly that's the only major change of scene for navigation bar stuff maybe there's more if there's more let me know still no image picker controller says he'll oh look oh he's right there is still no Mission Control I've seen you can have it yourself it's fine Oh tabs I have looked at the tabs tabs were terrible in iOS 13 let's see if they're better in I was 14 it's great fun isn't it let's - a navigation view with a list of 1 through a thousand ID self I in and text row I so that is a fairly mediocre list of stuff and it used be the case if you had a tab view somewhere it would misbehave woefully if you had stuff here I have multiple content views in here let's find out if this is good or bad maybe a lot of tab bites and perhaps a bit hard to read so down here tab item let's do image who crikey system name of what I don't know SF symbol tell me do some symbols let's use pencil dot slash great that's a great example pencil pencil dot slash and then text tab okay let's see how that looks let's see this is better than it was I was thirty it was really bad and I was thirteen now let's go down and then go to tab let's go around a bit and make the first tab you know that is better that's much better okay so they've got rid of the hideous white flash now she it retains where he for her you're the case that if you had you know navigation here somewhere if you had navigation link navigation link here link and a crankier to destination of text detail is this improve this find out it's exciting look out figure it out together a little bit here you see the case you would go here choose an item change tabs go back yes remembered your state small nurses of iOS fourteen yeah is there embers of state now it's a big improvement yeah so let's tab use it what's great now is that image picker in fifty why no there's not there's not sadly still we wrap it in the hundreds of Swift you I grabbed it there so they look it out you want to Oh app store overlays work now um they're not much submitted mobile could show you how it looks if we had a let's do that state at state private show apps equals false there's a new modifier called App Store overlay on show recommended apps do you know upsell your customers to buy more of your apps and you could say something like button show each key says keep was terrible oh ah ah and where's done we'll just toggle that show apps boolean and a modifier to this called app store overlay and this thing and you're gonna give it some parameters to work with the thing to bind you for start is gonna be show apps and the configuration is slightly trickier you can say SK over overlay last require socket doesn't it let's put in Setauket SK overlay boom dot I know Sears app clip configuration ooh and app configuration whoo and these things you can configure the how you want to you might say I want to provide in the identify of something I'm not sure what mind you let's do position bottom Chapel is in the way again there we go I didn't identify it let's go and find one unwrapped boom bring it map free learn Swift in the app store love it there's my app identify and it's paste that into there and this is gonna have a Glee work in the simulator yeah a little better preview basically show kind of works boom that thing slides up saying yes go on and get this app from the app store so you can upsell customers which is very nice so that is app store overlay let's do one more thing I'll be talking for an hour and I keep getting more and more excited yeah doubly see that difficult time for me I get so excited a tiny to calm down sharing it helpless you're talking about helps I'm slowing down the more easing this a little bit I'm so excited Jeremy it's only if you look at the very carefully doesn't say it doesn't say it's real oh hey Mark how you doing if you look at it says very carefully this is just a Developer Preview it's not the real thing you got to use a real outfit a real thing on there sprite kit Brian I've wants to break it right I already made an example for this I'll show you how it works it's really really nice and simple and it looks great out of the box all right let's bring a sprite kit I love sprite kit and I wrote a book on sprite kit it's called dive into sprite kit it's a choose your own adventure book where you make choices along the way and the project's adapt your choices it's really pretty cool anyway this thing has to have some sort of game seemed to show some solve s case scene subclass and there's one a normally used to demonstrate this which is a game scene inherits from SK scene scene and you go do did move to boom and we'll make a physics body for the whole world to have SK physics body using edge loop from edge loop from that one our frame and then we'll do touches began when they press the screen will do first guard let touch equals touches dot first else return pull out the first touch they mate then find the location of the patch in the screen location let location equals touch that location in self find where am I see now is pressed then make a box for that using SK sprite node and I'll use the color size initializer color will use UI color dot red yep UI color it's not sort of UI you just yet dot red what's your system ready for nicer of a size will do a CG size of width fifty height fifty so it's nice and big on the screen well I get a position will do box dot position is that location and box dot physics body equals SK physics body using a rectangle of there we go see sighs CG size width 50 height 50 an odd child box to add the box to the main sprocket area and now we're gonna do is make that seen somewhere in here that's important if you do not give it a size it will render very very badly you'll be completely confused I certainly was and offer me doing sprite kit work that have an S case file defining the size of the scene I don't have them here because we're free of that gnat or 50 white or programmatic so I'll do it in code instead but you've got to give it a size all wise ain't gonna work so we'll do vas seen seen seen is an S casing and then let's sing in equals seen come on Hudson a game scene I'm not better typing this you know and then seen dot size and crikey equals a particular size you've got to give it size width 300 height 400 and then seen seen dot scale mode equals dot fill fill hot screen and send that back so it can be used by whereas call in property now inside our main body we can say I want a sprite view just a new sprite view a sprite kit plus swift UI wrapper to put it two together so we can say I want to load my scene and when I put it inside a frame of width 300 height 400 like that let's give it a try hopefully we'll get ya brilliant yeah let's make it so much fun here is just get anywhere near enough to love quite frankly yeah so that's sprite get directly inside swiftly why I'm running at native speed I would say this is beta 1 it does make my laptop ramp up its fans very very quickly so I'm gonna kill the program before it sounds like you've got airport nearby right folks that is one hour of me chatting literally as fast I possibly can how everything new in 50 why for iOS 14 if you have feedback if you want more videos like this go ahead and like the video go ahead and subscribe to the channel do all those nice YouTube things and if you want I can hang out a few questions like a 10 minutes so otherwise it's back to writing for me as you can tell I am totally psyched i dub dub DC for me is the best day of the year it's great fun so I am excited to carry on playing around and writing stuff and experimenting and breaking and fixing and breaking again you know I love it yeah I lived this stuff it's great fun Steven are Cowie loves you instead no last year I had my own mini lab totally back to them I was sitting there on the floor in the fifth to IQ and folks just kept asking me questions and I answered them because I happen to be available so it was fun but um yeah do I have big soon I do not have big sir I do not is a a fire I am NOT going near looks gorgeous though I think that's absolutely beautiful I love the new redesign I want it I want it very much but not just yet Jeremy no I can't it's not certainly hard to do but I don't want to noodle around and screw it up on camera I probably I'll probably write something up shortly about it so I'll screw it up too much Oh so one dislike the video thanks for that folks I'm trying my best you know you can dislike if you want to it's down to you opinion our MacBooks I can't wait I've applied to the developer transition kit program so I'm looking forward to getting one of those our max through paying my 500 bucks towards Apple which I'll keep and then return the hardware it just seems so it's slightly scary but never mind I'm just keen to see how it does but I think it's an extremely fast is it as a short version is Xcode beta burning Swift 5.3 yes it is it's good I love us with five three great changes this is why all the documentation uses the new multiple training closures and tax by the way to video dislikes yeah never lied you folks anyway what I like most about Swift dua updates huh I don't really know because there's so many things to think about right now honestly the really minor thing it is SF symbol for Mac OS was a joint I believe the reason was NS image the way it worked and the lying is different from where it works from UI image internally so it wasn't easy to make better symbols on on on Mac and so you could have as have symbols in UI kit have symbols in iOS with you I and cunningly have SF symbols in UI kit and it's with UI in catalyst on Mac but not in app kit like anyway so yeah fortunately now Mac OS 11 does support SF symbols which is great that's really nice to see it's a lovely little framework third and and Rios asks how are the doctor dy they're good they're not great they have a long way to go still but they are an improvement and I'm glad to see Apple making headway with documentation hopefully the beginning of the whole brave new world tom is Swift see wiper action ready I think honestly now the thing that's missing art enough to hold you back I wasn't missing missing missing compositional collectionview layout that's annoying missing attributed strings may I can do it album missing text fields in alerts annoying but I can live without it so the small things missing like visual effect for you it's not a problem I can live without those things so you can do everything you want to this point six fifty why so yes I recommend you go check them out are you icings deprecated no they're not that because there's still a bad API vu like it they're not going anywhere it's just they're taking it out of the way for so if tyx is quite messy wasn't very swiftly wash so last question here at swift UI and my books so amazingly well done so if you i-team amazingly I've seen not a single piece of breaking code everything that worked before what correctly now just great very impressive feat to do that it's all additive that I've seen no breaking changes yet which is great so all my books a hundred seven I want to do you know the grids I want to do ladies that wanting more but right now they're all totally valid you know yes we have alerts interview I since day one they work great you can just google that it's on my site there's an example code units look through it it's cool what does that recommend to use in place of attributed strings text folks don't realize that the text view is super flexible if you have certain like you know text hello dot font large title dot whatever dot foreground mmm color red you can then do plus I have text world dot font dot title dot foreground color blue and stuck him out I might end up being one view it'll blend it two together to make one more advanced Beauty hello Soyoung detects plus tax plus tax plus text that's the way they're asking for us to do it it's not as powerful as attributed strings that's that's for sure I think we can't miss it at this point but it's what got and so it stuck with apples perspective was that you when you use attributed strings you're throwing away lots of metadata you know what each thing as an atom was you lose that in one bigger tribute string of course you do and so it's nicer having separate texts that's their picture this any improvement of split view not that I've seen Leonardo it's it's just there is innovation view Zack for me and my brain is one minute past 10:00 I'm on Houston time currently I not sure why I chose Houston I could've chosen Chicago apparently but who stammers at first I thought of officially it is four minutes when it passed four so yeah it's a late in the UK how do you manage different color navigation bars 50y so at this point I believe you still have to use a UI appearance proxy to do that which is not ideal salvage try if let's yes if networks now if they looks great you need a flat array you can say bar username is an optional string killed by default and now say I want where let's give us some code here if let user name is username then text of is your name here's oops here's your name and that works now which is great image system name of I need to memorize some system names I never amber these things let's do it free first what I saw so yeah I can you can now and optionals inside your function builders and switch thank you much Holland switches and if let now work and I think I said earlier I think it's Doug Gregor but I wouldn't want to say that to confidently because last time I did they had a go at me saying no it's a team effort so um yeah probably Doug but you never know we'll see yes kilo suggests the dub dub DC community repository gonna have a look at this because you got to get harm WC you will see this thing here where you can if you are writing anything about dub dub come to your own links here about 50 Y right combined or a are killed if you want to hear you want your your like it stuff featured or app killer watch kit link it there and I'm gonna send folks your way and I said folks your way to your articles you'll content your videos your cool code tweets so go ahead and link to it and there'll be nice I'll paste that into the chat window more or less okay right folks that is now five minutes past 10:00 Chicago time apparently oh thank you everyone for coming pleasure having you here and I might come back tomorrow with some UI kid stuff or more stuff to I so fire now I'm gonna find out I'm still exploring this stuff I'm still bringing out I'm having a lot of fun right now I'm as you might imagine extremely excited about all my Swift my good days to play with but let me know on Twitter if you like this go see more like it and I'll see you next time I guess take care folks bye
Info
Channel: Paul Hudson
Views: 29,450
Rating: undefined out of 5
Keywords:
Id: uitE6bmeFxM
Channel Id: undefined
Length: 70min 27sec (4227 seconds)
Published: Mon Jun 22 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.