Portal: Still Alive

This was a triumph. I'm making a note here: HUGE SUCCESS, It's hard to overstate my satisfaction. Aperture Science: We do what we must because we can for the good of all of us except for the ones who are dead, but there's no sense crying over every mistake. You just keep on trying 'till you run out of cake and the science gets done and you make a neat gun for the people who are still alive.

NSDictionary to NSArray


Usually I write in spanish, but since this is a universal issue (at least for the people who code in objective-c) I’m going to post this “answer” in english.

I was struggling for a couple of hours with something that in the end was very simple, trying to put the values and keys of a NSDictionary in a NSArray to order them, I’m a N00b, yes. But that’s how we all started, so hopefully in some months I will be less N00bish. I was trying at first with this code:

 NSArray *array = [dictionary valueForKey:@"Root"]; 

But when I was iterating the array

for (int i=0;i<=[array count];i++)


NSDictionary *item = [array objectAtIndex:i];


The debugger send me a error message telling me that I was in fact wrong, and the NSDictionary can’t use the objectAtIndex. Wait, what? but it’s an array!!!  Well, I was telling the NSArray at the beging to work as a NSDictionary and I was unaware.

What I found out was that I needed to send all the values instead of using the valueForKey. And that was it. Solution served, easy indeed.

 NSArray *array = [dictionary allValues]; 

Learning Cocoa


Puesto que tengo una memoria de pez, y la retentiva de un niño de 4 años  tengo que leer constantemente como hacer tal o cual cosa, pues me olvido con facilidad; aunque aprendo más rápido viendo a otros hacer, eso sí. Uno de los blogs que más he usado para programar en Objective-C han sido los siguientes:



Haz click en la imagen para ir al sitio