Change $PATH in Mac OS X Mountain Lion

I’ve had a bad time trying to get Jewelry Box running on Mountain Lion. I simply didn’t know how to edit my current $PATH.

Turns out there is a list it takes from at /etc/paths

I quickly changed the order and then after a trip to thew ‘brew doctor’ everything seems fine and now I’ve got ruby 2.0.0!

After much searching this is the great resource which I found:

Change order of PATH entries on Mac OS X

Chaining UIView animations with blocks

I really love UIView animations. They are so simple and elegant. This little chain I will make will fade in a UIView (or descendant) from the left, wait a moment, then fade out to the left. In general you can animate all of these properties: frame,bounds,center,transform,alpha,backgroundColor,and contentStretch in a UIView animation block.

For this example I created a single view application and put a UIImageView in the middle of the screen. UIImageView is a direct descendant of UIView so it is perfect for this exercise.
UIImageView
Continue reading

UITableView Disclosure Indicator on a UIButton

Although it is non-standard. I needed to match pixel-perfect to a design, so I created this. On a UITableView it is called ‘Disclosure Indicator’ as opposed to the one available from UIButton which is ‘Detail Disclosure’.

table_indicator

It is 50×80 with a transparent background. Use this image on top of a button or UIImageView. Resize it to whatever size you’d like your button to be. Apple recommends a hit target of no less than 40×40. I sized it to 10×16 in my storyboard, but I am using a transparent button overlay so the size doesn’t matter.
Continue reading

Configure a UIScrollView entirely in Storyboard with Interface Builder

Usually even if you drop in a UIScrollView, put a UIView into that and align them correctly it still does not work. Why? It’s UIScrollView.contentSize. Now we can easily do this in code, but it is also easily accomplished in Interface Builder.

The first thing I’ve done is drop in a UIScrollView, pop a UIView inside of it and then populate my controls into said UIView. We can verify this by looking at the hierarchal view.
UIView inside UIScrollView
Continue reading

Searching an NSArray of NSDictionaries

NSPredicate is the simplest way to do it.

Given Data like this:

NSArray *theArray = @[@{@"id":1,"name":@"one"},@{@"id":2,"name":@"two"},@{@"id":3,"name":@"three"}];
NSPredicate *p = [NSPredicate predicateWithFormat:@"id = 291"]; //fiber
NSArray *matchedDicts = [theArray filteredArrayUsingPredicate:p];

There is much more to NSPredicate. I used exact matching, but matching with BEGINSWITH, CONTAINS, ENDSWITH, and LIKE. In some examples you’ll also see [c] or [cd] next to these keywords. The ‘c’ means it searches case insensitively and the ‘d’ means that an ‘o’ with an umlaut is still just an ‘o’.