Big Nerd Ranch: Advanced iOS Programming Day -1

On 04/03/2012, in Big Nerd Ranch, Cocoa Touch, English, Objective C, Training, by frr149

Advanced iOS Programming I arrived yesterday to Atlanta, GA for a week long iOS training at The Big Nerd  Ranch and will be blogging the whole experience in English and Spanish in hope that it might be useful for other fellow nerds considering the same training on Advanced iOS Programming. The flight from Madrid was [...]

Tagged with:  

Apps’ kid! Six grader kid talks about his successful apps

On 18/11/2011, in Cocoa OSX, English, by frr149

So you were proud of programming in BASIC when you were eleven? Think twice: Apps’ kid

Tagged with:  

New free video lectures from Stanford University

On 17/11/2011, in Cocoa Touch, English, Objective C, Training, by frr149

Stanford University releases new free video lectures Stanford University improves its already incredibly generous display of free video lectures. After  Paul Hegarty’s iOS Programming Course and Peter Norvig’s (sic!) Artificial Intelligence, Stanford releases the following free video lectures: Computer Science 101 Software as a Service (SAAS) Human Computer Interfaces Game Theory Probabilistic Graphical Models Natural Language [...]

Stanford releases the latest iPad and iPhone Application Development Course

On 15/11/2011, in Cocoa OSX, Cocoa Touch, English, Objective C, by frr149

Latest iPad & iPhone Application Development Course The University Of Stanford has released the latest iPad and iPhone Application Development Course. The Fall 2011 course, with Paul Hegarty includes topics such as: Tools and APIs required to build applications for the iPhone platform using the iPhone SDK. User interface designs for mobile devices and unique [...]

Tagged with:  

State Machines in Cocoa / Objective C

On 10/11/2011, in Cocoa OSX, Cocoa Touch, English, Objective C, by frr149

State Machines State Machines model systems that can be in any of  a limited number of “conditions” (states) and moves from one to another according to a fixed set of rules. An example would be an object that represents an http connection. It might be in any of the following states: idle request-started request-sent request-timeout [...]

Tagged with:  

RotatingViewController: Display a different UIViewController depending on the orientation of the device

On 10/11/2011, in Cocoa Touch, English, Objective C, by frr149

RotatingViewController Sometimes you may want to display a different view in landscape and portrait mode. A good example is Apple’s Calculator: it switches from normal in portrait mode to scientific in landscape mode. There are several reasons you may want to do so: Your view is very complex and it’s impossible or very difficult to reuse [...]

Tagged with:  

Reducing cyclomatic complexity in your Objective C code

On 09/11/2011, in Bloques, Cocoa OSX, English, Object Oriented Design, Objective C, by frr149

Cyclomatic complexity The need for control structures is greatly diminished in Object Oriented languages if compared to other languages. Usually polymorphism provides a better and more scalable alternative to complex and nested conditionals. As a matter of fact, Smalltalk doesn’t even have a switch statement or method. In Objective C we have mostly two techniques to [...]

Implementing booleans in Objective C as objects

On 09/11/2011, in Bloques, C, Cocoa OSX, English, Objective C, by frr149

Booleans Just like GitHub’s Octocat, Objective C is the result of mixing very unlikely bedfellows: Smalltalk and C. Smalltalk is a pure Object Oriented language, designed and loved by “software artists“. On the other hand, C is the “software artisan” language “par excellence”: performance and practicality is paramount. The end result is a compromise that occupies [...]

Tagged with:  

The software artist and the software artisan: two types of inheritance

On 08/11/2011, in English, Object Oriented Design, by frr149

Inheritance Consider that you are asked to implement a series of classes to draw geometric shapes. Never mind the details or even the programming language, just the expected behavior of the classes, and most importantly the structure of the class hierarchy. You have a class Square and a class Rectangle. Both must calculate the area [...]

Objective C is just like Cobol

On 24/10/2011, in Cocoa OSX, Cocoa Touch, English, Objective C, by frr149

Objective C I spent this weekend teaching an Introduction to Cocoa-Touch course in Madrid. As usual, you always end up learning something new from your students, but yesterday was special. Baffled by Objective C‘s verbosity, specially the splitViewController:willHideViewController:withBarButtonItem:forPopoverController: (phew!) method from UISplitView, one of my students remained silent for a while, and then smiled with his insight: – Objective [...]

Tagged with:  

How to safely send @optional protocol messages that might not be implemented

On 24/10/2011, in Bloques, Cocoa OSX, Cocoa Touch, English, Objective C, by frr149

@optional methods in Objective C protocols Objective C 2.0 added support for @optional methods in protocols. Whatever class conforms to the protocol, it won’t be forced to implement “empty” methods if it doesn’t need them. This is certainly handy for the client conforming to the protocol. Unfortunately, it makes life miserable on the other side. [...]

Tagged with:  

Variadic methods in Objective C

On 24/10/2011, in C, English, Objective C, by frr149

Methods that accept a variable number of parameters It’s very common in Cocoa to find methods that take a variable number of parameters (ending in nil). For example, see NSArray’s arrayWithObjects: or dictionaryWithObjectsAndKeys: in NSDictionary. In both cases, the method will loop through our list processing each element until it reaches the nil. How to create our own [...]

Tagged with:  

How To Display Transparent Modal ViewControllers

On 20/10/2011, in Cocoa Touch, English, by frr149

Transparent Modal View Controllers I recently had to add a semi-transparent modal view controller on an app that I’m building for INSEAD. I was expecting to call  -presentModalViewController:animated: while modifying the alpha and opaque properties of the modal VC. It didn’t work. The “problem” is that iOS is very finicky about not wasting memory, and since [...]

Tagged with:  

How to avoid a circular import error in Objective C

On 14/10/2011, in Cocoa OSX, Cocoa Touch, English, Objective C, by frr149

Circular import error in Objective C This morning I was treacherously bitten in the butt by a circular import error. In order to help you avoid this same kind of error I am summarizing my findings. #import best practices to avoid circular errors in Objective C An #import in your header causes that header to be imported [...]

Tagged with:  

Free video lectures for Harvard’s “Mobile Applications in html 5, iOS and Android”

On 01/09/2011, in Cocoa OSX, Cocoa Touch, English, Objective C, by frr149

Mobile applications in html 5, iOS and Android Harvard has made its Computer Science E-76: Building Mobile Applications course free online. It includes video lectures and source code samples in PDF. The course covers today’s  3 main technologies: Html 5 , iOS and  Android free lectures, the iOS section includes iPhone and iPad programming, and the instructors are Dan Armendariz and [...]

Tagged with:  

Comparing Objects in Cocoa / Objective C

On 11/07/2011, in Cocoa OSX, Cocoa Touch, English, Objective C, by FRR

Comparing Objects in Cocoa: Object Equality in Cocoa & Objective C Cocoa defines several methods for comparing objects in Cocoa: isEqual:  isEqualToClassName isEqual: compares the receiver to an object and will return NO if the object doesn’t belong to the same class as the receiver. isEqualToClassName: compares the iVars of two objects of the same [...]

 

UIPopoverController for iPhone

On 09/07/2011, in Cocoa Touch, English, Objective C, by FRR

UIPopoverController on the iPhone Even though there is a UIPopoverController in Cocoa-Touch, it only works on iPads (at least with iOS 4). iOS 5 might add support for iPhone, but until then you may use WEPopover.

 

How to change the highlighted background color of a UITableView’s cell

On 09/07/2011, in Cocoa Touch, English, Objective C, by FRR

Changing the background color of the selected cell in a UITableView The default value for selectedBackgroundView is nil for cells in plain-style tables (UITableViewStylePlain) and non-nil for section-group tables (UITableViewStyleGrouped). If you’re using a plain-style table, you must alloc an init a new UIView with the desired background color, and then assign it to selectedBackgroundView. [...]

Tagged with:  

NSDate: Working with dates in Cocoa, creating and decomposing.

On 28/06/2011, in Cocoa OSX, Cocoa Touch, English, by FRR

Create a NSDate from its components (day, month, year) You don’t use a init method in NSDate, instead, you use a method of NSCalendar (dateFromComponents:): Method that initializes a NSDate form an ISO 8601 date representation (YYYYMMDD):

Tokenize a NSDate into its components (day, month, year, etc…) You also use a method form NSCalendar(components:fromDate): [...]

Tagged with:  

Two staged creation in Cocoa and Objective C and why we need it

On 22/06/2011, in Cocoa OSX, Cocoa Touch, English, Objective C, by FRR

Two Staged Creation of objects in Cocoa and Objective C Unlike other OO languages such as Smalltalk or Java, Cocoa separates memory allocation from instance initialization. The very first versions of NextStep had single creation methods, as in Smalltalk. This was changed, because of the need of several different allocation strategies to cup with the [...]

Sorting objects in Cocoa

On 10/06/2011, in Cocoa OSX, Cocoa Touch, English, Objective C, by FRR

Sorting objects in Cocoa: Sorting using selector (in ascending order) This is the most common sorting method for sorting objects in Cocoa. It uses a selector that must return an NSComparisonResult (either NSOrderedAscending, NSOrderedSame, or NSOrderedDescending). The most common selector is compare:.  MUST be declared in header file, as NSObject doesn’t implement it. All custom [...]

Tagged with:  

How to add a static library to iOS project in Xcode 4

On 07/06/2011, in Desarrollo XCode, English, Objective C, by FRR

Static library to iOS After struggling for a while to include CHDataStructures to my iOS project, here’s a step by step guide that will allow you to add any static library without losing your mind. STEP 1: Add the static library sources to a Source Tree Go to XCode preferences and select the Source Trees tab, add a [...]

Tagged with:  

Reducing the “syntactic castor-oil” in Objective C

On 07/06/2011, in English, Objective C, by FRR

Reducing the “syntactic castor-oil” in Objective C with explicit collections I just finished reading “Regarding Objective-C & Copland 2010″, where the author discusses if Objective C can be considered a “modern language”. The provided description for a “modern language” is arguable (and I certainly don’t agree with all the points), but Objective C seems to [...]