C99 initializers

You probably know CGRectMake, but did you know it’s not the only way to make rectangles? It’s not even the best way, really. There’s also C99 initializer syntax. The main advantage to the C99 syntax is that it gives you some very Objective-C like syntax, where the fields are close to the values rather than… Continue reading C99 initializers

Why you should use instancetype instead of id

In my previous entry, I discussed when id will be promoted to instancetype. But now that I’ve explained this, I’d like to explain why you should understand this but not rely on it. Instead, you should use instancetype directly. Let me start with this bold statement, then I’ll back up and explain it: Use instancetype… Continue reading Why you should use instancetype instead of id

A primer on @property and dot syntax

Properties were new in Objective-C 2.0, introduced in 2006. While pretty uncontroversial, along with them came dot syntax. Dot syntax is much more controversial. In this article, I’ll discuss the advantages of @property which make it worth using, and discuss “dot syntax.”

Objective-C property proposal: mainthreadonly

I’d like to propose a new language feature for Objective-C, a property attribute that would indicate that a property should only be set from the main thread. Let me be clear: Objective-C does not do this. But wouldn’t it be cool if it did? @interface CustomView:UIView @property (mainthreadonly) NSString *title; @end

Reachability

Apple has a sample code package called Reachability. It wraps an iOS framework called SystemConfiguration, and can be used to determine network status, and catch events about networking going up and down. In the past, it’s been an ugly chunk of sample code, but it’s pretty respectable now. One thing Reachability is not, however, is… Continue reading Reachability