May 2012
4 posts
3 tags
ARC, or why you will love LLVM
Don’t take me wrong, I strongly believe that anyone writing a compiler deserves my respect. Is not a task for the feeblest. Yet, my relationship with GCC was not always a good one. How not to hate the cryptic messages spilled by the parser from time to time? Well, let’s praise Stallman irreducibility, Apple condemn GCC and replace it with LLVM1. Regardless of the actual reasons, the...
Los momentos de mi vida en los que yo he crecido, tienen que ver con los...
– Marcelo Bielsa
1 tag
Product Definition
Time after time good ideas are wasted in poorly designed apps. The problem, usually, is the lack of understanding of the target of the app, and how the app is going to be used in the real world. The world of the app has to be chartered before the first line of code. We have to figure out what we are going to deliver to our customers in advance. We have to be intentional. No real world architect...
March 2012
9 posts
2 tags
Patching git
Perhaps one of the less known, and yet more useful commands in the git interactive add is patch. Let’s say you start working on a file to fix a bug (yes, I know, your code does not have bugs, but let’s pretend for a moment), Once in the file, you found a line that needs some refactoring, and just because you are a really nice person, you add some comment to a method that has nothing...
2 tags
Authorization Code flow in depth
Authorization Code flow in deep
Perhaps, one of the most secure flows in the OAuth specs, because the access token is never exposed. The authorization is accomplished using an authorization code that then is traded for the actual access token in a server-to-server exchange. The client has no access to the access token. The flow starts when the resource owner is redirected to the API provider. In...
2 tags
OAuth Authorization flows
OAuth defines four different grant types to obtain authorization:
Authorization code: After the resource owner has authorised access to the data, he or she is redirected back to the client application with an authorization code as a parameter in the callback url. This code is then traded for the actual access token. The process is performed server-to-server and requires the client_id and the...
2 tags
OAuth 2.0 Debate
It is there all the time, one of the most important task for engineers is to strike a balance between security and usability. You can build a pedestrian bridge performing a load rating for big trucks, but is going to be expensive, and harder to build. The same is also true in software engineering. There are zillions of reasons to prefer OAuth over other protocols, but some engineers found it hard...
3 tags
OAuth
OAuth has a bad reputation. many claims that it is hard to implement, and some are really confused by the flow. And is a shame, because OAuth is a wonderful protocol to ensure how we want to share information. This is the first of a hopefully not so long series of post to explain how to use OAuth.
First, we are going to take a look at the basic terminology.
Authentication: This is the process...
3 tags
Menu Controller
The Menu Controller is the main tool to let users edit data on device. It is a singleton that you can use to present the cut, copy, and paste menu. The message is percolated though the responder chain, until it find a suitable controller to perform the command.
Being a singleton, we don’t need to worry about initialization, we just need to instruct the shared instance where it needs to be...
3 tags
Dispatch Queues Types
GCD is a terrific technology introduced by Apple, first in OS X and then in iOS. The very basic core of CGD are dispatch queues. Queues are there to let as work with threads, without having to know, and worry about, anything about threads.
Queues can be classified as:
Main Queue: This queue is linked to the main thread. Because the UIKit classes are not thread safe, if you need to contact any...
1 tag
Scope of variables in blocks
Local variables behave just the same as in any Objective-C method.
For blocks defined inline, local variables also includes the local variables for the method the block was defined in.
Because of that, self is only accessible for blocks defined where self is also accessible. Since inline objects copy the local variables of their lexical scope, beware the use of self to avoid ownership loops....
January 2012
1 post
1 tag
A Brief, Incomplete, and Mostly Wrong History of... →
December 2011
5 posts
Programming, Motherfucker →
3 tags
Twitter Integration
With more than 3000 apps integrated with Twitter, is not really a big surprose to learn that iOS 5 adds APIs to make things even easier.
If all we need to to allow users to push tweets from our apps, then it is really easy. All we need to do is to link the ´Twitter.framework´ and then import Twitter/TWTweetComposeViewController.h where we need it. TWTweetComposeViewController is basically a...
3 tags
Werror or GTFO
There are a few useful warnings that should be set in any Xcode project. Here them, and why you should care:
Mismatched Return Type Warns if a function does not declare a return type, or if the return type is not void, but a return statement is found without a return value.
Sign Comparison You have a signed and and unsigned comparision. This warn will let you know if the result is incorrect...
1 tag
November 2011
1 post
2 tags
Not always faster
A few weeks ago, I was asked how to sort an array, and I was prompt to answer “using GCD”. Bilal LoLo (@anabillo) ask again “why not NSSortDescriptor”, and I was “because GCD is faster”. Is it? Well, there is an obvious way to know. Truth be told, I was using sort descriptors before GCD was introduced to the phone. And when it was introduced, I automatically...
October 2011
3 posts
2 tags
1 tag
Instagram Engineering: Sharding & IDs at Instagram →
instagram-engineering:
With more than 25 photos & 90 likes every second, we store a lot of data here at Instagram. To make sure all of our important data fits into memory and is available quickly for our users, we’ve begun to shard our data—in other words, place the data in many smaller buckets, each holding a part of…
3 tags
When the deal goes down
I’m pretty sure that your code, as mine, never has bugs. It just develops random features. But you know, sometimes sheet happens, or at least that’s what I’ve been told.
In Cocoa there two mechanism to deal with, let’s say, random features. Exceptions, and error reporting. Apple strongly recommends not to use exception like in other platforms. In Cocoa, exceptions are...
September 2011
8 posts
2 tags
Something and nothing
NSValue
Many Cocoa classes, like NSArray and NSValue only takes objects as parameters. What to do when you have a non-object value you want to store? Simple, use NSValue.
Let’s say we want to store a [CGRect struct] [1] into an array.
CGRect rect = CGRectMake(0, 0, 300, 300);
NSValue *rectValue = [NSValue valueWithBytes:&rect objCType:@encode(CGRect)];
NSArray *array = [NSArray...
1 tag
Basics →
Talking about basics, a must see for anyone interested in Objective-C / Cocoa.
4 tags
Back to Basics
Primitives
Primitives are defined by Objective-C, not by Cocoa, they are not objects, we can think about them as the atoms of Objective-C
The most basic data type is the integer or int. An integer is a whole number, that could be positive or negative. 42 and -74 are integers.
By default, variables of type int are signed, which mean that they can represent both, positive and negative values....
15 tags
2 tags
4 tags
Core Data Classes
The very basic functionality of Core Data is to store objects. Each object should be defined presenting the entities to be persisted, and the relationships between them.
Core Data provide a set of classes to deal with this whole “model definition” issue.
Model
* `NSManagedObjectModel`: A model is where we describe a collection of entities. Is like an *schema*
*...
If our ideas seem smaller nowadays, it’s not because we are dumber than our...
– The Elusive Big Idea - The New York Times (via domleca)
Thought provoking, indeed
6 tags
Internationalization and Localization in iOS
iOS and Cocoa in general is well know for providing a wide range of internationalization,almost for free. Let’s take a look at these technologies
API Name
Description
NSLocale
Properties related to the current region, including formats
NSNumberFormatter
Formats and parses number
NSDateFormatter
Formats and parses dates and times
NSCalendar
Support for various types of calendars...
May 2011
1 post
1 tag
April 2011
2 posts
3 tags
2 tags
IPv6 on iOS
iOS 4 and IPv6
iOS 4 incorporated the full network stack of the CoreOS, that means, basically, support for IPv6.
Apple has added initial support for DHCPv6 for DNS server addresses, search domains, etc. Essentially, the Core Network layer uses the stateless capability of IPv6 to gather the IP address, but uses DHCPv6 to get other important information.
Any code that uses CFNetwork, already...
March 2011
2 posts
4 tags
February 2011
1 post
3 tags
January 2011
1 post
3 tags
November 2010
3 posts
cars10 asked: Heya Volon!
Do you know if it is possible to send/receive layer 2 ethernet frames (on raw sockets) on an iPhone / with iOS ?
Thanks and best regards,
Carsten
Do you know if it is possible to send/receive layer 2 ethernet frames (on raw sockets) on an iPhone / with iOS ?
Thanks and best regards,
Carsten
1 tag
if you’re not embarrassed when you ship your first... →
1 tag
October 2010
15 posts
4 tags
Size does matter
One of the most daunting challenges for the iPhone app designer is not the size of screen, but the fact that its input device is no other than a human hand. With a mouse, or a stylus, you can get precise input, down to the level of the pixel. With a human finger, you don’t, even worse, most of the time, the screen is going to be partially covered with a hand. In fact, there is no physical...
3 tags
What is Mobile
To better understand what kind of applications are suitable for a mobile device, we might need to consider the mindset of a typical user when he or she is more prone to use a mobile app. Typically, he or she needs to perform a really simple task, or wants to know what is around, or just kill some time playing or entertaining him or herself.
Simple Task
It is really tempting to deploy a whole...
5 tags
Application Definition Statement
Mobile platforms are very special. By definition, people that uses mobile apps are moving. and thus has no time to spare for an app.
People, real people, uses apps in all kind of contexts, and a wide range of environments, but frequently, the user attention is divided between the app, and the real world. Most users has no time (neither are interested) in immersive processes, but in tomorrow...
4 tags
4 tags
Protect Data in Transit
One of the weakest points of any application, is the information interface with the outside world. This is particularly true for iPhone apps.
Nowadays, the vast majority of devices that run OS X are mobile. So we need to be suspicious of things like Domain Name System, and the local network in general. Traffic on a wireless network can be easily monitored, and tampered with by a third party....
3 tags
Running Privileges
So, we have seen a little bit about security, let’s focus on the topic a little longer.
The actual way applications are ran, varies enormously from desktop to phone. On desktop applications can run with administrative privileges. On the phone apps are ran inside a sand box. That’s why we are going to talk a little while just for desktop development.
So, one of the most important...
5 tags
Stack Overflow
A few days ago, my dear friend Adrian Kosmaczewski published a wonderful article about C and C++ as the foundation of a good Cocoa coder. He was kind enough to let me read a draft, and i have to say that reading his excellent review of the memory architecture, I remind the olds days exploiting buffer overflows for fun. Fun? you may ask, and yes, it is fun to try to understand the inner workings of...
2 tags
Creating UI assets for the iPhone OS →
6 tags