Posts

Showing posts with the label arrays

Lynda Course - Swift 5 Essential Thinking (Part 2)

Image
A bit of time for some Swift before bed! Made some good progress last time - covered a lot of the basics and consolidated well. Let's go! Start Time - 20:37 3. Working With Collections Right, playground file open and ready to go! var levelDifficulty: [ String ] = [] var otherArray: Array < String > = [] I tend to use the first way (if empty array).  Various use of .count, .isEmpty etc.  An out of range exception error happens when trying something in the array that doesn't exist.  Core Array Methods Nice recap! // Changing & appending items var characterTypes = [ "Dwarf" , "Elf" , "Goblin" , "Ranger" ] characterTypes . append ( "Orc" ) //Inserting and removing items characterTypes . insert ( "Wizard" , at: 5 ) characterTypes . remove (at: 4 ) // Ordering and querying values var reversedCharacters = characterTypes . reversed () characterTypes . sort ()...

Stephen DeStefano Swift 5 Course - Part 8 (Lectures 32 to 38)

Image
Yes, two in a day! As mentioned earlier, I want to crack on and get the technical stuff DONE! Just want to get on to the projects. So the plan is to get at least collections done, then hopefully enumerations (maybe error handling too!) Start Time - 20:08 Arrays Again, as with other stuff in this course, I know this well so more of a skim through. A couple of cool things. The default value part is the same item repeated basically. The adding two arrays together means a bigger list basically. Can use the isEmpty property. Then use that within an if statement. Other stuff insert at, append, remove all etc. So using the range ... to put in several values at once. Iterating over the array. Use of the if let to see if an item is in the array. Use of sorted function. Then 'by'; you can use the < or >. Or others probably! Quiz - 10 out of 10 and one of the easiest so far! Dictionaries The syntax and concept of these is absolutely fine. Key-value pairs...

*CONSOLIDATION ENTRY* Nick Walter Challenge Revisited!

Image
So, I was happily coasting through the beginner and intermediate aspects of Swift in Nick's course when WHAM! The challenge was just so tough. To be fair, I could have been much more willing to search for how to do the various elements. So I'm going to have another go at it, trying to do what I can from memory. I will then see if I can find out where to get the info from.  Start Time - 11:29 Right, first off let's see what the challenge was... So that is the task! Here is what should be returned as an example So I am going to, again, try this without any help at all, remembering what I did yesterday. Yesterday was such a rush and I didn't even attempt to look up how to complete the different parts to it. Right. Various elements to this. As before, I know that I need the following elements - A function that takes in a string I am going to print rather than do a return String as that it is too fiddly! A way of putting the string into separate values in...

Sandra L Course Part 2 (lectures 11 to 15)

Image
Before I begin the second part of Sandra's course, I made a couple of final (I know that I should just leave it!) tweaks to How Many Letters. One flaw was that the number in the text box would still be there after clicking the button. That's fixed now! Was actually quite easy - a function that basically changed the value in the text box to an empty string. Also, I added a button with a segue to an information page.  Start Time - 21:24 So I'm cracking on with Sandra's 'easy' course - the first bit was anyway. Hopefully it'll be more challenging soon but not make the giant conceptual leaps that Bob's code did! Collection Types: Arrays var numbers: [ Int ] = [] numbers . append ( 4 ) All fine to be honest.  There are various in-built functions with these that you can apply e.g. remove at last, remove all, count etc.  This is all VERY easy. I'm a bit concerned! Going to crank up the speed... Dictionaries Main difference...

Bob Lee Course Part 7 (lecture 11)

Image
So a long old time! Unavoidable unfortunately - parents' evenings, car renewal (complicated in Dubai!), my girlfriend's friend staying, going into work over Half Term to get things sorted before an upcoming inspection...yep - busy! Sadly, coding takes the worst of this as I simply haven't had the time nor brain capacity to even consider it. Yet I'm making some time for it! Time in between getting back from work - during Half Term and all - and heading out to see people this evening. Once Cath's friend has gone tomorrow, I'll hopefully be able to better balance things.  So....last time with Bob it was about classes and structs, and when to choose between using these. A lot of that was familiar but it was good to confirm that classes, being a reference type, are tricky to use as the original values change. Anyway, moving on today with tuples! *By the way, I've gone back to naming this by lecture rather than lesson, as what Bob calls 'lessons' do ...