Joris Kluivers

I like to build software.

Examples of Sites Using Media Queries

A big part of responsive web design is the use of media queries to enhance a page based on different viewing contexts. Most often this means changing the page styles/layout based on the page width. This makes it possible to optimize a website for different devices using only css.

Mediaqueri.es is a gallery of websites that take advantage of media queries in css. Click a demo and resize your window!

Launching the Twitter App to a Profile, With Web Fallback

To give users of your iOS app the option to follow you on twitter, you could open the webpage of your app account. Better yet, why not just open the Twitter app itself? Most twitter users probably have the official client installed. Using the custom url scheme supported by the Twitter app, you can display your account profile directly. Users are now only one tap away from following you.

Singletons in Objective-C

I recently switched to a new way of implementing singletons in Objective-C. Since most of my code now is iOS 4.0+ I started using GCD and blocks as recommended by Luke Redpath (ARC compatible):

Xcode 4 Snippet: Calling a Delegate Selector

Another code snippet I find myself using a lot. Check if a delegate (usually self.delegate) responds to a selector, and if so call it:

1
2
3
if ([self.delegate respondsToSelector:@selector(<#Selector Signature#>)]) {
    [self.delegate <#Delegate Method#>];
}

Fully Customizable Activity Indicator View

The idea of re-implementing standard UI components from iOS has been floating around in my head for a while now. The UI kit controls and views are great, but when working with designers you’ll notice they always tend to tweak everything a little. I’ll always advice you to use the standard controlls wherever possible, but wouldn’t it be great if you could customize the color or change the size a little bit?

I recently came across the Spin.js which implements a activity indicator using css and javascipt. This lead me to start working on my own customizable view for iOS, usable in native applications.

Resize a UIImage the Right Way

When deadlines loom, even skilled and experienced programmers can get a little sloppy. The pressure to ship may cause them to cut corners and look for a quick and easy solution, even if that solution is sure to cause trouble later on. Eventually, their coding style devolves into copy and paste programming, a lamentable tactic that involves cherry-picking snippets of code from a past project and putting them to use in the current one. Trevor’s Bike Shed

A great write-up on the risks of ‘copy-and-pase coding’. Solutions to coding problems found online might not always be the correct answer, they usually lack testing and might even contain hidden bugs. I’ve ran into posts like this on multiple occasions (both iOS and Android) where the most popular answer clearly was wrong. The problem is that not everyone will actually be able to see this and use the code as is in a project.

There’s a lot of wrong code floating around the net related to manipulating UIImage’s for example. Correct solutions for common UIImage manipulation tasks are discussed in the post Resize a UIImage the right way in the form of several UIImage categories.

Xcode 4 Snippet: Logging the Current Method

Another quick snippet: log the current method. The code for this (no template variables):

<code>NSLog(@"%s", __func__);</code>

Snippet configuration Usage

<code>lm<span style="color:#666"><tab></span></code>

Get the iPhone UDID

A short guide on how to get the iPhone UDID:

  1. Connect your iPhone to your computer and start iTunes

  2. Select your iPhone from the devices list on the left, and move to the summary tab.

  3. Click the serial number label in your phone summary.

[caption id=”attachment_52” align=”aligncenter” width=”822” caption=”Serial Number label”][/caption]

  1. You should now see your UDID similar to the following image:

  2. Select copy from the edit menu, you can now paste the UDID in any email[caption id=”attachment_54” align=”aligncenter” width=”231” caption=”Select copy to copy the UDID to your paste board”][/caption]

#pragma Mark in Xcode4

Xcode 4 introduces a subtle improvement over the older version. Marking sourcecode with headers now only requires a single line:

#pragma mark - Descriptive title

Combined with user snippets it is now a two character sequence for me to add a title to my source code. The snippet template I’m using:

#pragma mark - <#Description#>

Using this snippet adding a mark is as easy as typing:

pm<tab>