Day 7 at Mobile Makers (Custom Delegation, Modal Segues)

Today was by far the hardest day for me personally. We focused on a combination of custom classes and custom delegation and it was pretty foreign to me. I plan on spending our four day weekend (because of memorial day) coding all day, everyday to really grasp the concepts. I am going to design an app that incorporates everything from week one and this week combined so that I can really get the concepts. A cool thing I learned today was that you can set the editing property of a UITextField to on or off to allow or disallow editing within. Delegation allows you to know things that are happening like taps and stuff while custom initializers are done at the beginning whereas delegates can be done anytime. A little cool Xcode trick I learned is that when Xcode is doing autocomplete and you don’t want it to, just hit escape and it will stop.

I was working with Robert today and he came across a really cool method called NSPredicate. It looks like this…

NSPredicate *diceEqualsFive = [NSPredicatepredicateWithFormat:@”value = 5″];

NSArray *diceWithTheNumberFive = [array filteredArrayUsingPredicate:diceEqualsFive];

Basically what it does is it looks in an array and checks for, in this example, a value that is equal to 5. Once is does that, it returns how many it found of that value and we can then manipulate and use that data even more.

I am going to get some rest and get ready for a weekend full of non-stop coding.

 

-Blake

Day 6 at Mobile Makers (Custom Classes, Segues)

Today we worked with UITableView’s and I learned some really cool things. First being that you need to reload the table view after you change it so that it can update. You do this by saying [self.myTableView reloadData]; it is really simple and a very useful thing to memorize. There is a method that is called commitEditingStyle that you use to make it so a user can delete a cell of a tableView with the handy swipe gesture.

We can implement a new class with the subclass NSOjbect and then declare properties within it and reference these in other view controllers. I believe this is what we will start doing more and more to put less code in the view controllers. You can also add a segue to a tableView and it is really simple. You simply drag from the tableViewCell and onto the new view controller. This automatically puts a disclose indicator on each tableView cell, which is pretty cool. Then in the new view controller you can add an unwind segue to a back button or whatever else and go back to the view controller while passing data and/or reloading the tableView with the method mentioned above.

We also touched on fast enumeration today in class and it basically looks like this…

for (Dragon *dragon in self.dragons) {
NSLog(@”dragon: %@”, dragon);
}

Dragon is the type of object and *dragon is just saying it is an instance of Dragon for each item in the self.dragons array. This will do whatever is in the statements to to each item in the array.

A really cool method I learned about today is called componentsJoinedByString. This is what it looks like…

[self.selectedMagicalCreature.accessories componentsJoinedByString:@”, “];

This method takes a bunch of items, in this case all the accessories listed for a specific magical creature and puts a comma and space between them. The items in the .accessories are stored in a mutable array.

Tonight Naomi, Rich and I went to a networking event at Dev Bootcamp and got to check out there space and meet some of the students that had just graduated from there. The topic of the night was about Ruby in motion and it basically allows developers to build iPhone apps using Ruby and it was really cool. The students we met had built a geocatching app using Ruby and it worked on the iPhone! We got to check out the space and it was really cool and they also have three classes going at once in three different phases. I’m going to try and keep going to different events throughout my time at mobile makers.

-Blake

Day 5 at Mobile Makers (TableViews, Arrays, Fast Enumeration)

I came in pretty early this morning, around 7:30 and met with Kevin for about an hour. I was having a few bugs in my tic tac toe artificial intelligence and wanted to get a second opinion on it. Kevin really helped me out and showed me some new tips and tricks as well. The BIGGEST take away point from working with Kevin is to initiate exception breakpoints in Xcode. This will allow Xcode to show you where specifically your app crashes and that is extremely helpful. Kevin also showed me how to used #define. Basically, you say #define kNumberOfSeconds 2.0. This sets a constant to 2.0 named kNumberOfSeconds and you can put this constant anywhere in your code and it will be complied into your code before your code is run. Just to refresh on some basics too. Primitives are int, float, double, BOOL, CGPoint, long etc…and do NOT have a pointer (*). Only objects have a pointer (*) and only objects can go in an array, not primitives. Something else I knew but never really thought of is that IBAction methods return void. Also, with a bunch of if statements, each one will evaluate while if you have if-else statements once the correct condition if found it is done.

Today we started UITableView’s and they are really interesting. We only touched on the basics today but I can already see that there is massive amounts of things we can do to manipulate Table Views. Our hackwitch consisted of making an array with corresponding numbers inside each row of the table view starting at zero. Then we had to change the color of the row and add colors to different rows as well using a button. This hack witch showed us the basic methods that must be implemented when using table views and as always, don’t forget your delegate and data source methods.

Tableview’s can go from very basic to very in-depth rather quickly and I think we will see more of that tomorrow. I plan on building a small app later in the week that builds off of all week 1’s concepts as well as week 2’s.

-Blake

Week 1 Weekend Review

This weekend was full of coding and I’m perfectly fine with that. I got so much accomplished this weekend from building a tic tac toe app to building an app that combined everything from the previous week to building a connect four game app with changing colors. On Thursday I completed the MVP for the tic tac toe weekend challenge and on Saturday and primarily Sunday, I really looked into the artifical intelligence aspect of it. Being able to play against a computer is almost a given in games these days and it intrigued me as to how complicated it would be to accomplish this, even in a game as simple as tic tac toe. I started by declaring an array of the different labels which I was using to hold the text of the user (and computer) on the screen (9 of them total). I then was able through much manipulation to be able to get random objects out of this array and assign them the text “CPU” if it was the users turn. After getting the basics down, I moved onto how to give the computer some actual intelligence and be able to block the user from winning and to take advantage of opportunities when it could win instead of merely just randomly picking labels on the board. I accomplished this with many upon many upon many if-else statements. It was really good practice and showed me how quickly code can accumulate in a project. Just for this small tic tac toe project, I had over 400 lines of code. I can only imagine what large scale apps and I’m excited to find out.

My connect four app game used the same basic principles as tic tac toe but with the added coolness of being able to switch the colors around of each label as the user was actually trying to connect four. I did this using a cool method called performSelector…this allowed me to set a “delay” on when it would fire and I set it to 1.0 second. So every one second a different label out of the 16 labels for the connect four game app would change colors. I also started all the labels off as having different colors at the beginning of the game. The cool part about this method I discovered is that you can make a quick strobe light by setting the delay to a very small number such as .002 or something like that with many different colors. I also learned you can clear an array by saying [arrayName removeAllObjects]; and that will definitely be useful when resetting games such as in the tic tac toe game.

This weekend was a lot of fun and a lot of the other students were at the space all weekend. Being around other people who love to code and solve problems is something I have been looking for, for a long time and I’m so glad I finally found it. When everyone works together and is willing to help one another, it makes for a great environment and the learning possibilities are endless. Aaron and I are still working on our calculator app from day one, we have just been busy tackling other projects but plan to finish it soon.

I’m excited to start another week and keep learning.

-Blake

Day 4 at Mobile Makers (Properties)

I’m writing this blog on the metro heading home after a long but productive day at Mobile Makers. I arrived at the space this morning at 8am and stayed until a little after 11pm. Today we did gestures and they are really tricky and I am still struggling with them. The method names for some of them are not very intuitive and I think that is what is throwing me off.

We built off a really great concept from yesterday more today and that is helper methods.  DRY stands for “don’t repeat yourself.” Basically, as programmers we don’t want to repeat ourselves and helper methods “help” us do just that or “help” us don’t do just that depending on how you look at it. Helper methods take a block of code that we have used multiple times within our program and allow us to just call the helper method within other parts of our code where the blocks of code used to exist. You call a helper method by saying [self thisIsMyHelperMethod];. This is a really awesome way to make your code more readable.

Our challenge today and spanning into the weekend is to build a functional Tic Tac Toe game with a lot of extra features. I have written more if and if-else statements than I ever have before in my life but it is great practice. Going into the weekend there is 4 stretch goals for the Tic Tac Toe game and I plan on working on them throughout the weekend. I want to focus a lot on redoing the material from the week in different types of small apps as well. A random thing I learned today was that you must have a UIAlertViewDelegate  and set the delegate as self if you have more than one button in your alert view.

Today was a ton of information and I just need to take the weekend and process it all. I will be at the Mobile Makers space all day, each day this weekend working on everything and will hopefully have a clearer understanding and be able to explain everything more later this weekend.

-Blake

 

Day 3 at Mobile Makers (View and View Controllers)

We hit the ground running today. There were a lot of questions from the class about the PrepareForSegue method and then unwind method and the answers to those questions helped me a lot. You can send all kinds of information like an NSString through the PrepareForSegue method. On our challenge yesterday the first stretch goal was to have a UITextField on the first view controller where the user could input their name into it and they would be the protagonist in the story. We weren’t able to finish this goal yesterday but after today and Max going over the code again, I was able to go back through the Adventure project and get this to work and complete the goal. I was really excited about this because it took me about 1.5 hours to configure each view controller and then also to add outlets to each UITExtView to be able to change the text where the protagonists name will go.

Dennis was my partner  today and we had a pretty easy MVP but very very very challenging stretch goals for the third day. I like it though, the are really challenging us if we decide to accept the challenges. We finished the MVP in about 15 minutes and then worked on the stretch goals for around 4 hours. We learned a lot today and I really love the pair programming. Being able to combine two minds and have two different points of view is really a great thing and allows us to solve problems quick and in different ways. Dennis really knows his stuff and I learned a lot today not just from the exercise but just how things work and the flow of things in Objective-C from him. So far I have been able to complete all the stretch goals each day and that was my goal coming to Mobile Makers. I know it is only going to get harder but I am excited for the challenge.

The most beneficial thing I learned today was about github. I was really struggling with this before today but I think I finally have it down, or at least the basics of it. Basically, you go on github and create a repository. I have been naming them whatever the name of the project is. Then in the terminal, you find your folder of your project. Usually you do this by saying “ls” then cd Desktop/Xcode/Adventure. Xcode is the folder on the desktop the Adventure project is in. Once there, if it is the first time, you say “git init” This initializes the project for the first time. Then you say “git add Adventure” and then “git commit -a -m “Initialize project” The -a stands for all and the -m stands for message which in this case in the “Initialize project.” Then if it’s your first time committing you have to go to git and copy and paste a line of code. After that you say “git push -u origin master” this pushes your file onto github. This is my understanding so far after Day 3 and it might not be exactly the steps but I have committed three projects to github so far.

A few cool random things I learned today were that to delete a breakpoint really quick and easy, just click it, drag off onto a different part of the screen and release it. That makes it “vanish.” Another cool thing was that IB in IBAction and other things stands for Interface Builder. We used a lot of delegates today and they are really cool but you have to make sure you hook them up to the view controller! Delegates communicate things that are going on and have specific methods tied to them. You can look the methods up in the apple documentation. Dennis and I used a lot of pragma marks today too and he taught me a cool little trick that if you write #pragma mark – Text Field Delegate that the hyphen will put a full line in the bread crumb where that pragma mark is. All of the little things I am learning are going to really start piling up and make a world of difference in the future.

I left today around 7pm and feel really good heading into Day 4 and I’m excited for the weekend challenge and to keep learning more.

-Blake

Day 2 at Mobile Makers (Xcode and Storyboard)

Starting on day 2 we got right into coding and it was intense. We focused all day on basically two methods: prepareForSegue and then another IBAction method that “unwinds” the prepareForSegue method. By unwind, I mean it reverses something or takes you to a place you have already been.

I learned some really useful small tips today that will go a long ways in the future. To start, you can assign properties in the .m (implementation file) just like you can in the .h (header file). This allows you to keep your properties private. The rule at Mobile Makers is to put everything from the storyboard you assign a property to in the .m file. Another cool thing I learned is that within any action, you can call the resignFirstResponder method on a keyboard. So for instance, if you have a UITextField named myTextField you and you want it to hide when you click a button called Calculate, then within the action of the Calculate button you would put [self.myTextField resignFirstResponder]; pretty nifty!

Max told us that fizz buzz is a very popular interview question and we need to become very familiar with answering it. Basically it uses the modulo (%), which returns the remainder of two numbers divided.

So I had a variable named result and the code was like this: result % 3 == 0 && result % 5 ==0. This code was in a if statement and checked to see that the result variable number was divisible by 3 and 5. Both of those were true if the result was 0. But Max taught us that you can find a common number and just use one number so I changed by code to: result % 15 == 0. I did this because 15 incorporates a number being divisible by 3 and 5.

A very cool trick we learned today is that if you do Command-Control-E and click on a variable in your code, it highlights everywhere that variable is and you can change its name across all of your code. Very cool!

Now the hard part: The prepareForSegue method…..

Within this method you must set the destinationViewController equal to a variable. The destinationViewController is the view controller where you are sending the information in the segue. After doing this, you set each unique identifier on each segue. This is going to come in handy later. Then to access a particular segue you check to see what its segue identifier is equal to.

if ([segue.identifier isEqualToString:@”BlueStar”]) {

//code goes here….

}

the if statement above is checking to see if the segue identifier is equal to “BlueStar” and if it is, it will do the code written below it in the statements.

We also learned some cool stuff about images today. All images need to be in PNG format and we need to put all images in the images.xcassets section of Xcode. You can import images into this and then once in it, it is good practice to make sure that all images are in 2x format, which is for retina display. I learned a valuable lesson today that there is a sort of hierarchy to writing code. I had wrote code to change the background color and then under it to add an image on the same view controller, well my image wasn’t showing up. Turns out that is because my image was hidden behind the background. So I simply switched the code and the image was then on top of the background.

Naomi was my partner today and the afternoon MVP and stretch goals were very challenging. We were tasked to create an adventure game that had text in a UITextView and then users selected one of two buttons depending on what they wanted to do after reading the text. Naomi and I got a little carried away with our story but it turned out really cool. Below is a picture of it.

 

Snip20140513_3

 

It is hard to see but we have 12 view controllers total, each with a different part of the story on it. The lines going to and from them are the segues that I was talking about earlier. Our story had a lot of twists and turns to it. We completed the second stretch goal by adding a riddle to a view controller and the user had to input the answer they thought was correct using a UITextField. If they got it correct, a button would appear for them to proceed to the next step in the adventure game. They user couldn’t proceed until they figured out the correct answer to the riddle! It took us awhile, but around 8pm we finally figured out how to properly implement the stretch goal. Today was fun and challenging, some people were stressed but I have decided to look at problems as a opportunities to learn more and expand my knowledge and I know I will have many more opportunities each day.

Overall, I feel pretty good about the material today. Git and github are still very challenging for me but Naomi showed me the basics on it and I already feel better. Basically you have to make sure you are in the right folder and branch and then when you are ready to commit your project to github you….

git add Adventure

//Adventure is the name of our project

git commit -a -m “This is the message to attach to the commit”

//-a stands for all

//-m stands for message

git push -u origin master

I believe these are the correct steps and then your project will be on github for all to  see. I am going to really get into git tomorrow and ask a bunch of questions about gitx. I’m excited for all the “opportunities” tomorrow.

-Blake

 

Day 1 at Mobile Makers (Classes)

I arrived at Mobile Makers around 8am. When I arrived I was greeted by Brandon and Don with a friendly smile and a warm welcome. Breakfast snacks such as fruits, cereal bars were laid out and coffee was brewing (I have never drank a cup of coffee in my life but I might start if the long hours get to me while at Mobile Makers). All the other members of the cohort started filing in shortly behind me and we all gathered around and exchanged greetings while waiting for the day to officially start. At 9am we all moved to the main teaching area and all the teachers, starting with Brandon, introduced themselves and touched on their different roles at Mobile Makers. During his presentation, Brandon really drove home the idea that as a student, you need to have a thirst for knowledge and strive for above and beyond what you thought possible. The teachers are here to guide us and push us, but they can only take us so far if we aren’t willing to push ourselves.

I really like the concept at Mobile Makers which is to teach/learn for 90 minutes and then take a 10 minute break. It gives the mind a few minutes to process and take a step back and then feel refreshed when it’s time to start again. The first app we did today was a simple app that used the User Interface (UI) label and button elements. We made it so that if the user clicked the button, the background color of the label turned blue and the text of the label turned white. I was pretty familiar with all of the concepts covered in this simple app and it was a nice refresher and segue into harder material.

After creating the simple app as a class together, we broke into teams of two for pair programming. Aaron and I partnered up. Him and I had been emailing weeks before the cohort began exchanging ideas, talking about problems we had come across and showing each other material that we had found helpful for learning while doing the Treehouse prep material. Our minimum viable product (MVP) challenge for the day was to create a simple calculator that took input from the user in the form of a UITextField and multiplied it by the number 10, which was stored in a label. The user would hit a calculate button and the result of this multiplication would be shown in a results label. Aaron and I tackled this challenge relatively quickly and then we moved to the stretch goals. Stretch goals are extra goals to challenge us (the students) even more on each project. I plan on attempting to complete these each week to get the most out of the program. The stretch goals for today included adding a UISlider, taking its value, inputing it into a label and then also being able to use it as the second number to multiply the UITextField’s number by. We had a little trouble to start but eventually completed the stretch goals. We set the value of the UISlider (self.sliderName.value) as a instance variable and then set it as the label’s text and then also into the results variable that multiplied the UITextField’s number by the slider value. We also added an IBAction to the slider so that whenever it was moved, the text in the label that showed the value of the slider was updated.

I feel pretty confident heading into Day 2 and look forward to the rest of the challenges this week. Everyone was extremely nice (teachers and students alike) and I can’t wait to start working with everyone and coding more and more.

 

P.S. – Aaron and I stayed after for a few hours and started on a complex project (for us at least) that we are going to be working on as we have time. We are building a calculator very similar to the standard one on the iPhone and it is a lot more complex that we imagined. We are hoping that we can take what we learn each day and continue to build upon it. The layout we created is below.

Snip20140512_1

 

-Blake