Girl Develop-it

This week I helped with and iOS programming class for Girl developit meetup, hosted by Joe Burgess. The format was little to no pre-requisite programming skill, so the students were writing their first for loops and if statements.

Objective-C is a difficult first programming language, so one thing Joe said in the class stuck with me, that was:

it’s not that anyone is smarter than you are, it’s just they’ve been doing it longer.

He said this a couple of times throughout the lesson and the exercises. I think its a great thing to ground yourself. When something seems un-attainable to grasp in your understanding, it just takes additional time.

Many problems in code come down to your mental model not fitting to whats happening. So you need to debug the code, and adjust your understanding. For that breif period you feel stupid, but it also can be a fun challenge. That is coding.

Xcode Shortcuts

Ctrl + Cmd + J Jump to definition (under the cursor)

Ctrl + 1 Show related items, from here you can select super classes or recent files

shortcut 2

Ctrl + 6 Show document items (methods outlines). Start typing to filter

shortcut 2

Ctrl + a Move cursor to start of line Ctrl + e Move cursor to end of line

Some more well known:

Cmd + Shift + j Highlight current file in group folder view

Cmd + Shift + o Open quickly

Ctrl + Cmd + Navigate back a file

Ctrl + Cmd + Navigate forward a file

Unit Testing Block Based Callbacks

I recently tackled unit testing my AFNetworking client classes, which use block based callbacks, stubbing out block callbacks took some trial and error so is worth of a blogpost.

Take the example method:

- (AFHTTPRequestOperation*)meWithSuccess:(void (^)(AFHTTPRequestOperation *operation, NSDictionary *responseObject))success
                                 failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure

How would you go about mocking/stubbing this method call? One way is to use OCMock expectations. In your unit test setUp:

self.stubMessagesPayload = @{
     @"has_mail" : @0,
     @"has_mod_mail" : @0,

_client = [OCMockObject mockForClass:[AFRedditAPIClient class]];

[[[_client expect] andDo:^(NSInvocation *invocation) {
    void (^__unsafe_unretained successStub)(AFHTTPRequestOperation *, NSDictionary *);
    [invocation getArgument:(&successStub) atIndex:2];
}] meWithSuccess:[OCMArg any] failure:[OCMArg any]];    

In the actual test, you can change the value of stubMessagesPayload and assert different behaviour. You’ll also notice the block argument is located at index 2, from the documentation:

Indices 0 and 1 indicate the hidden arguments self and _cmd, respectively; these values can be retrieved directly with the target and selector methods. Use indices 2 and greater for the arguments normally passed in a message.

The other issue you may face is how to get your class to actually use the mocked version of your object. The code under test may look like this:

[[AFRedditAPIClient sharedClient] meWithSuccess:^(AFHTTPRequestOperation *operation, NSDictionary *responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

The only way to stub a class method is via swizzling, which can get messy. The alternative is dependency injection, whereby you expose object dependencies using properties or constructor varaibles. Then they can be swapped more easily at runtime, so if the AFRedditAPIClient object where a public property, and RCMessageClient were the class i wanted to test, expose the dependency using a property and in the test asign it to the mock object:

_apiClient = [OCMockObject mockForClass:[AFRedditAPIClient class]];
_messageClient = [[RCMessageClient alloc] init];
_messageClient.apiClient = _apiClient
Additional stubs explained above

And the implementation changes to refer to that property instead of the class method:

[_apiClient meWithSuccess:^(AFHTTPRequestOperation *operation, NSDictionary *responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

E3 Visa Expedition

This post is about a recent US tour I took with the goal of finding work as an iOS Developer in New York. In March of this year I made the decision to quit my job and take the plunge. I was solo, and planned accommodation only 1-2 weeks in advance, so had a huge amount of flexibility.

Another factor for the timing was the WWDC conference. I didn’t get a ticket the amount of side events and altWWDC made it more than worth it.

I was there for 4 months, did a lot of of sight seeing also, but we’ll skip over that.

Getting around

I was ‘on the cheap’ so flew Jetstar Melbourne > Honolulu ($700) then Honolulu > Vancouver ($220). Once on the mainland the Megabus and Greyhound were the preferred mode of transport. Both cheap and allow for great flexibility, the clientele can be pretty rough though.

Looking online

I stayed away from traditional job seek sites, the amount of recruiter spam seemed massive (cybercoders??). Resources:

Events / Meetups

Every city hosts tech meetups and networking events, some resources for meetups:


I had about 20 interviews before landing a position, split 50/50 between phone and face to face. Numerous companies follow the Google approach of

  • 1 or 2 phone screens
  • 3-5 interviews in one day, each interview with one person.

Each interview was one or two coding questions and some general resume interogation. Having a portfolio of public facing apps is expected, if not then some open source projects.

Code questions

I found the following process to be helpful for programming questions, taken from: Programming problems : A Primer for the technical interview by B. Green. A summary:

1. Reframe: say the problem back to the interviewer, allowing ambiguities to be addressed. And a way to get hints

2. Write test cases: Builds upon step 1, confirms you and your interviewer are on the same page, will help you formulate your solution. Truth tables, expected output for input, corner cases. write them all down without writing the solution

3. Diagram a solution:(e.g): There’s not many general purpose helpers here, hopefully you will have an idea of how to approach the problem based on the test cases and your discussions with the interviewer. Think out loud, they will provide hints if you are stuck.

4. Coding : I like to start start high level and invent lower level functions, keep variable/function names short as possible.

5. Run the test cases from #2: Confirms your solution and allows interviewer to critque

See also:Interviewing the InterviewerCandidate Coaching Session

E3 Visa


The formulation of documents for my visa was handled by visanow. The process took abou 3 weeks but was pretty straight forward, they have a checklist style interface and good customer service.

visa list


Held at St. kilda road Melbourne, I had booked for 9:30, arrived at 9 and waited until 10:30 to be seen. There’s an airport style security check where you’ll relinquish any devices.

I bought everything listed from visanow along with some bank statements, bring everything you think will help, but don’t forget:

  • Printed copy of interview confirmation page
  • DS 160 confirmation page
  • Letter of endorsement from your employer
  • Labour condition agreement (ETA form 9035 & 9035E)
  • DHS Form G28


Almost hard to belive once it happens, the pipe dream is a reality. My role as iOS Developer at Meetup starts in a few weeks, one adventure ends and another is beginning. Thanks for reading.

Fast HTML Rendering Without UIWebView

This project was created for amrc as a means of rendering HTML rich text content.

The library is built on xml parser hpple. htmpple uses NSDictionary merging to produce an NSAttributedString that represents the given html. Only a subset of html tags are supported, they include those available to any rich text editor, layout such as table is too complex to render with just NSAttributedString.

Rendering non-hyperlink content is a peice of cake in iOS 6 due to the support added to [UILabel attributedString] . If the HTML contains links there’s a bit of additional hacking required. I’ve included a subclass of UITextView to assist with this, although you may want to consider delving into CoreText aswell.

The helper method htmlDataContainsLinks is used to detect hyperlinks and mitigate the performance hit when using UITextView

Check out the project on