Tuesday 22 January 2013

Git Alias & Ignore

Quick Reference for Git Aliasing and Ignoring

Aliasing:


$ cd ~
$ vim .gitconfig

Add the following (and any additional shortcuts you want):


[alias]
ci = commit
st = status
co = checkout
lc = log ORIG_HEAD.. --stat --no-merges

Ignoring

(This is mine for a rubymine project)

Thursday 10 January 2013

Network JSON request in iOS


I had to dig a little to bring all the components together necessary for something like this so I thought it best to document it.

For the request you need: 

1. Create an NSMutableRequest
2. Create an NSURLConnection with the above request
3. Set the class encapsulating this behavior as the delegate to the connection
4. Implement the call back methods the connection makes based on the result it gets (so you can decide what to do)

Monday 7 January 2013

iOS 6 Facebook Integration

<script src="https://gist.github.com/4161726.js?file=AppDelegate.m"></script>

<script src="https://gist.github.com/4161735.js?file=AppDelegate.m"></script>

Add the plist item 'FacebookAppID'

Add the entry to URL types.

Knock this into a delegate method.

<script src="https://gist.github.com/4161746.js?file=gistfile1.txt"></script>

<script src="https://gist.github.com/4161750.js?file=gistfile1.m"></script>

Thursday 3 January 2013

Configuring Environment Variables iOS

Say you've got an iOS app talking to a backend api. Maybe this api runs as localhost on your machine when you're in development and maybe you also have staging and production environments out in the cloud somewhere. What's the best way to set this up?

I've gone with an encapsulated pList... setup as follows.

This is my pList file.
I encapsulate that in a class called EnvironmentVars.

After which, I can access it as follows from anywhere. This is an example of using it to create a NSUrl object.
Objective C code can be terse. I find it's best to exercise encapsulation to the extremist point to maintain sanity.