Day 12 at Mobile Makers (Auto Layout, Constraints)

Auto layout and constraints were the two topics of the hackwitch today. I am pretty comfortable with the basics of these because I did some tuitorials before coming to Mobile Makers. I think the key with these two items is to practice practice practice and try to have your app as laid out as possible in storyboard before putting constraints on objects.

Some things we re-went over today included delegates. A Delegate is a way for two objects to interact. They perform functions for an object without another object knowing about it. We discussed the app delegate for the first time and found out that it is loaded every time the app starts. So we want to limit what goes into it because it will take longer to load if we put too many things in it.

One topic for me that is still hard to wrap my brain around is blocks. I know blocks happen when we don’t know how long something is going to take when we are retrieving data from an outside source. They also almost always happen asynchronously, meaning in the background while other stuff is still going on. This benefits the app because it isn’t waiting for everything from the block to come back before moving on with other tasks.

A random cool Xcode trick I learned today is that when the stimulator is open, you can press command left arrow or right arrow and it will change from portrait to landscape view and vice versa. This is really useful when using autolayout and different constraints.

A small reminder I had today when building a project was that primitives are not objects, thus you cannot put them in an array. Only objects can go in an array. Primitives are bool, float, int, double etc…so you must have NSNumber when you have class properties that are numbers that are going into an array because NSNumber is an object.

image

 

Above is a picture of something I made while trying to understand maps and map kit better. It really helped to write everything out and step back and see how everything worked.

-Blake

Day 11 at Mobile Makers (CLLocation, MKDirections, MKLocalSearch

Today was the most challenging day so far at Mobile Makers by far. We got the location of the current user while also being able to find locations near that user based on a search. There are what seem like to be 10+ new class methods that were thrown at us today. I am glad tomorrow is the weekend so I can catch up and look through them all and read the documentation and really see what they do.

It was a challenging today but I am glad we are learning about maps and locations. It is an essential skill to master to be an IOS developer. I plan on doing a lot of mini side projects this weekend to really grasp the steps in being able to use maps.

One cool thing I learned today while Max was teaching, is that you can have a NSMutableString. With this mutable string you can append items to it so that you have a list of items or directions etc… Here is an example…

[directionsString appendFormat:@”%d: %@ \n”, x++, step.instructions];

The NSMutableString is named directionString and what we are doing taking each instruction in the step and assigning it a value of X, which starts at 1 and then increments up from there by one each time. The ++ after the X increments it and if you did minus minus on the other side of the X it would decrement it. So in this example, we are printing out directions to a location and giving the directions step numbers so they are easier to read. The \n makes a new line so that each numbered direction is on its own line. This was very useful to learn and I anticipate using it quite often in the future. BTW- we had the above code in a for loop that was iterating over the steps of a whole route and that’s how we were getting each one. Instructions is a property of steps, which is of class MKRouteStep.

Tomorrow is auto layout and constraints. I have a little practice with them and I know it is going to be extremely challenging. I’m excited to learn all the best practices associated with auto layout.

-Blake

Day 10 at Mobile Makers (MKMapView)

This week is the week I am most excited for. We are learning about maps and core location, both of which are critical to know when making apps. Today we started with MapKit and apple has already done a lot of the work for us. Within a few short steps, we can have a working map of the world and drop “pins” anywhere onto it. Today we used more JSON data and I am starting to get familiar with it and its syntax. On a lot of job applications I have seen so far they are looking for people who are well versed using JSON data so I am going to continue to work on my skills in this area more and more.

I learned a cool trick today that for placeholder text when setting a label or something put your variable first and then do     ?:       “Placeholder Text” this will set the text to “Placeholder Text” if the variable is nil. Pretty cool. Fast enumeration is going to be used a lot I believe and I am trying to practice with it as much as possible. Fast enumeration allows us to take an array or dictionary of objects and display them on a large scale, like a bunch of individual items on a whole map, by retrieving their longitude and latitude.We can create new objects each time when going through an array or dictionary.

Today I really dug into the documentation that apple provides and I learned a bunch. I am going to make it a goal to read the documentation first on my own before going to sites like stack overflow. Tomorrow is going to be awesome dealing with Core Location and I am really excited.

 

-Blake

Day 9 at Mobile Makers (Dictionaries, API, NSUrlConnection)

After an extend memorial day weekend, we were back at it at Mobile Makers and we focused on API’s. API stands for Application Programming Interface and it is a way to access data from a website like Instagram or Twitter etc… In order to do this in Objective-C, you must first declare a URL then declare a request. From there you can connect to the API and get information. Depending upon how the API is set up, it could either be a Dictionary or Array or a combination of either or both. Today we used MeetUp.com’s API and it was a Dictionary of Array’s with more dictionaries within. This was a little hard to wrap my head around at first but after thinking through the problem and getting a little help along the way from Don, I got it.

A random thing I learned today is that the cell of a UITableViewCell has its own image property that you can access when populating a UITableView and this allows you to put a nice image on the left side of the screen.Today we also really focused on dictionaries and basically they have “key” “value” pairs. So the key could be name and the value of that name is “Blake.” This is a way to reference large quantities of data and is really useful. The syntax is a little weird at first because they use {} braces instead of [], but after awhile, it becomes second nature. We accessed MeetUp’s JSON data this way today and using array methods as well.

I met with Kevin today and he showed me what the Model View Controller (MVC) is all about and I am going to start working on a side project under his mentorship to start focusing on MVC. I am going to do a matching game and it should be a lot of fun.

-Blake

Day 8 at Mobile Makers (Animation, Dynamics)

So today I got picked to show my code to the class and it was a lot of fun. I didn’t finish all the stretch goals but myself and Robert wrote some really good code and I was proud to show it off. I had a lot of complements after showing my code and one person even told me it was the best code walk through they had seen so far. The NSPredicate method seemed to really impress Don as well. Today was all about animation and during the hackwitch we made half of the game pong. It seemed like it was going to be really hard at first but after learning about the different tools at our disposal like collisions, behaviors and push etc…it really wasn’t that difficult. Xcode figures out most of the hard stuff behind the scenes, we just have to put the pieces together to make it work.

We had an assessment today and I knew the material really well, I just got hung up on one problem that I spent the entire hour of the assessment trying to figure out. I made a new custom class and in that class had a custom initializer method. In the .m of the custom NSObject class I was declaring the parameters of the method.

city = self.city;

state = self.state;

    return  self;

The above code is NOT how it is supposed to look within the custom initializer. This is what I had and I needed to say self.city = city; a small mistake but a lesson learned.

I have been working out the specs for a big weekend project that incorporates everything from week one and week two. I am really going to focus on the areas I am not comfortable coding and specificly focus on the Model-View-Controller as well as writing clean and easily readable code. Don showed me some cool tricks I will be implementing today. We have four full days to work this weekend and I’m excited to combine everything I have learned. Naomi and I are most likely meeting with our mentor tomorrow as well.

 

-Blake

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