agi18n agimagechecker amazonaws android arc autolayout blog building cache calabash certificates clean code cocoa cocoapods data binding debugging deployment target drm ebs ec2 errors facebook fix git i18n images instruments interface builder ios iosx enterpise summit ipad iphone iphone5 kotlin libraries like button linking links llvm memory management method swizzling mobile model mvc mvvm nil objective-c optimizations patch patterns performance presentation provisioning profiles restkit runtime rxjava rxswift security shadows streaming svn swift testing tools tutorials uikit uistackview video view xcode

Subscribe to this blog

Tag: objective-c

MVC in Objective-C (I): Introduction

Angel G. Olloqui 21 February, 2013


MVC stands for Model View Controller, and it is a pattern that allows developers to differentiate code depending on three different roles. It is extremely popular due to its simplicity and it is implemented in different ways in almost every single technology out there -in different ways though. MVC helps you making your code lot more reusable, maintainable and easier to extend
MVC image

Tags: mvc, objective-c, patterns


ARC (III) - ARC Optimizations

Angel G. Olloqui 02 November, 2012

In my previous two posts about ARC (post I and post II) I have talked about the optimizations and how ARC can perform as fast (or even faster) as manual memory management. This is quite clear when working with simple alloc/retain/release examples because it is exactly equivalent to manual memory management but using C calls (which are faster). However, I haven’t explain how it does it when dealing with methods that return autoreleased memory. So, it is time to have some fun.
First, lets copy again the resulting ARC compiled code seen in the first post:

Tags: arc, memory management, objective-c, xcode, optimizations


ARC (II) - Advantages, drawbacks and false myths

Angel G. Olloqui 26 October, 2012

In my previous post I analyzed the fundamentals of ARC. Today, I am going to write a quick post about some general advantages, problems and myths around it. I warn you that I will not enter in details, but it will be useful as an introduction to the next (and probably last) post of the series. 


There are many advantages of using it, but I would summarize them on the following:
  • It Keeps it Simple Stupid (KISS)! Working with ARC makes your code easier to write, read and maintain. Therefore, your code will be less error prone and you could actually save some time writing (specially in dealloc methods).
  • Safer: Do you think your code is secure without ARC? Yes, you know how to retain your instance variables, but, let me ask you if you always retain your temporal variables. Probably not always, right? In the end, if it is a temporal variable there is little point on retaining a variable and releasing it a few lines later right? Well, then check out the last example exposed in my previous post! You can never be absolutely sure if an autoreleased returned value will be available the full variable life time, so you should retain always autoreleased variables to be 100% sure it will work. ARC variables by default are strong, which means that they will be retained, and the compiler never forgets :). Besides that, the introduction of weak references can also help a lot in solving problems with released pointed objects (usually delegates).
  • Less leaks: If you are a master of iOS development you probably have few memory leaks or even not at all. However, even if that is the case is common to work with different people who might not be as experienced as you are. The use of ARC ensures that there is no leak due to an incorrect use of retain/release. However, be careful with the memory retain cycles! they are still there. 
  • Reduces autorelease pools: This one is pretty interesting because I thought that ARC would make heavy use of autoreleasing pools. However, that’s part of a false myth and we will take a look to it later. For now, all you need to know is that it actually reduces the amount of autoreleases in your code (if everything is ARC compatible though), which could make your apps to actually execute faster if your code produces heavy memory pools.

Tags: arc, memory management, objective-c, xcode


ARC (I) - Introduction to ARC and how it works internally

Angel G. Olloqui 11 October, 2012

It has been about a year since Apple released ARC, and even if there is a lot of good information out there I still see some misconceptions, false myths and reluctances to adopt it . Because of that, I am going to write a set of posts about it, but focusing in explaining how it works under the hood and why some of the myths out there are not really true.
So today, lets start by presenting ARC.

Tags: arc, memory management, objective-c, xcode


Method Swizzling

Angel G. Olloqui 18 May, 2012

Hoy voy a hablar sobre methodSwizzling, para mí una de las técnicas más apasionantes de Objective-C. Eso sí, aviso para navegantes, estas técnicas son complejas y, según el uso que les des, pueden también ser peligrosas. Vamos a verlo!

Qué es MethodSwizzling?

Probablemente nunca hayas oído hablar de MethodSwizzling antes, o si lo habías hecho, no sepas exactamente qué es o para qué puede servir. Pues bien, ese nombre se usa para referirse simplemente a la técnica de intercambiar métodos en runtime.
Es decir, se trata de que métodos que ya existan sean cambiados por otros nuevos durante ejecución, incluso en clases que no has prgramado tú (del sistema por ejemplo). A nivel conceptual puedes entenderlo como una category o una herencia que reemplaza métodos del padre, pero el MethodSwzzling, al ser en runtime, va mucho mas allá. Ahora veremos por qué....

Tags: objective-c, runtime, ios, method swizzling