Check Your CS193P Answers

If you want to compare your implementations of CS193P(Fall 2011) homework assignments with someone else’s you can check out i4-apps.com. The site’s author does note that he is no longer maintaining the site but that it will remain up for at least a short while. That means check it out sooner rather than later, if the link is dead you have missed the proverbial boat… of answers, the answer-boat.

Make the +/- Button For Assignment #1 Extra Credit

Below is my solution for one of the extra credit questions from assignment #1 from Stanford’s online CS193P class. Was trying to find a way to do it and found this post, it had an ok solution but the author mentions that a better solution would be something that manipulates the string instead of multiplying the display’s doubleValue. Here is what I came up with:

– (IBAction)plusMinusButtonPressed
{
    NSString *minusSymbol = @”-“;
    if ([self.display.text characterAtIndex:0] == ‘-‘) {
        NSRange myRange = NSMakeRange(0, [self.display.text length]);
        self.display.text = [self.display.text stringByReplacingOccurrencesOfString:@”-” withString:@”” options:NSLiteralSearch range:myRange];
    } else {
        self.display.text = [minusSymbol stringByAppendingString:self.display.text];
    }
}

DocSets: An Awesome iOS/Mac Reference

DocSets is a Universal iOS app that lets you download and easily browse Apple’s developer documentation. The sets available are for Mac OS X 10.6/10.7 and iOS 4.2/4.3/5.0/5.1 with sizes ranging from around 200MB to 500MB. DocSets also happens to be an open source project available on GitHub. So beyond all that referency-goodness you can poke around in its source code to see how it works, algebraic!

Piazza Makes CS193P on iTunes Social

Piazza must be Italian for ‘perfect timing’ because I just started working through the Stanford iOS classes last week. Piazza acts as a class message board so you can work with other people taking the class to ask questions, etc. The class will run from June 25th to August 27th, registration ends on July 6th. Here are the links to sign up for Piazzo and the class on iTunes U.

Updated: iOS Programming Resources List

Here is my running list of useful iOS programming resources from around the internet:

Cheat Sheets

 Books

 Videos

 Blogs

 

 

My Growing List of iOS Programming Resources

Here is my running list of useful iOS programming resources from around the internet:

Cheat Sheets

 Books

 Videos

#pragma mark: Xcode’s Patron Saint of Grouping

‘#pragma mark’ is a helpful directive for Xcode to help you organize code in an implementation file. With it you can group methods together for easy navigation, here is an example:

#pragma mark-

#pragma mark Picker Data Source Methods

And here is what it looks like in Xcode:

I like this much better than my previous system of making little comment headers for a group of methods, thanks Apress iOS 5 book!

Using GMP in Xcode 4 With the Help of GMPInt

One of the issues I have run into trying to solve some of the Project Euler questions is that some of the numbers are too big for any of the Objective-C primitives. Some Googling shows that GMP is the answer to my problems but being a pretty novice programmer I have had issues making it work, that is until I found GMPInt, an Objective-C wrapper for GMP.

Setup went pretty smooth following the instructions on the GMPInt Github page but there were a few issues. Here is the steps it took for me to get it to work: 

  1. Install Homebrew
  2. Run the command “brew install gmp” in Terminal, having sudo infront of that command gave me an error about being cowardly, but dropping sudo made it run fine
  3. Add the libgmp.dylib file to your project under Target > Build Phases >Link Binary with Libraries
  4. From there I had to correct the line ‘#import “/usr/local/Cellar/gmp/5.0.1/include/gmp.h”‘ to 5.0.5 as that was the version of GMP I had installed
  5. I also had to go through the GMPInt.m file and comment out any autorelease/release references as I selected ARC for the test project I made

From there I setup a simple test and ran the app, worked perfectly, now I can attempt some of the Project Euler problems I couldn’t before.