Monday, June 30, 2008

Happy Objective-C

I love Obj-C :D

What I learnt in today's reading:

NSObject - superclass of everything except your own root class [way difficult]

Classes as the object factory since each object is an instance of a class, therefore it's a class object.

Some similarities between instanceof and isMemberOfClass:someClass method.
and isKindOfClass:someClass method which tells if the object we are evaluating inherits from someClass.


Static Typing (ohh pointers here we go!) Useful for the compiler to do type checking

Rectangle *myRect <- This specifies that myRect is a pointer to Rectangle class and Graphic *myRect is also valid since Rectangle inherits from Graphic, therefore it can be statically typed like that.

Class Objects
The body of our object, meaning the method implementations, name of the class and superclasses, instance variables, declarations of methods and their return types.

Class can be typed id or to the Class data type

id aClass = [anObject class] or Class aClass = [anObject class]

Main function: to create new instances.

id myRect;
myRect = [Rectangle alloc];

what alloc method does is to dynamically allocate memory for the new object's instance variable and initializes them all to 0. But we've got to initialize even properly, not just to 0. ( there we go!!)

What we do to initialize is to surround the alloc with init, like this:

id myRect;
myRect = [[Rectangle alloc] init];

Just then myRect would be able to start interacting (e.g. receive messages). The structure is:
alloc returns an instance of Rectangle
init is performed by that instance to set its initial state

I knew I was inside the matrix!! There is a NSMatrix object!!

Messages rock! Look at this:

[myMatrix setCellClass:[NSButtonCell class]];
so what does this mean? (you can answer, you've learnt all the way with me!)
No clue? Well here it is...
NSButtonCell class returns what? A Class or an Id type therefore that is sent to setCellClass which is a setter to myMatrix NSMatrix object (previously initialized). Clear? No? One more time:
myMatrix is an object (instance) of NSMatrix. The CellClass that will be filling that myMatrix object is being defined by the Class passed to the setter method, NSButtonCell.

Class names can only be used in two ways. As part of a message (receiver) or as a type name for a kind of object. Since I've already explained this you should know it.

One new thing would be that if you don't know the class name at compile time but you will at runtime then use NSString *className
and create this monster:

[anObject isKindOfClass:NSClassFromString(className)]
So what does the last statement means?

That's it for today and you've got homework!!

Sunday, June 29, 2008

Today is a good day

No matter what I'll be posting about Obj-C today. I'm really desperate of reading some more and I can't because of this project. Just a question that doesn't need to be answered. What happens when we've lost our creativity? What if the eagerness of developing libraries or resources that can change the circle's sharpness dies?

Today, Obj-C.

Move on!

Come on!! Move on!!

As soon as I finish this damn project I'll be able to do what I WANT to do. This instantly translates to studying obj-c. I'm not at the pace I'd like and iPhone launch is merely two weeks away. I need something by next week or I'll be in serious problems.

Saturday, June 28, 2008

Absolut

No Objective-C news...sorry, damn school's project is killing me .

The good news is that I'm coding with Absolut Pears + Ginger Ale. Excellent mix!!

I'll get back later on!

Friday, June 27, 2008

Weekend arrived

Hey finally weekend!!!

I'll get some sleep tonight and tomorrow I'll be doing some SableCC thing. Although there is no submission I'd like to go one step ahead since the earlier I submit my work the earlier I'll know if it is correct.

And now...Obj-C :D

Saturday and Sunday I'll be reading some more chapters from the guide. I really need to learn. It's a challenge I'd like to face.

iPhone beta 8 was released today but I didn't install it. I'll wait to weeks more to have the final release.

Thursday, June 26, 2008

Lack of energy

Hey! Thanks for staying tuned. Today I won't update since I' tired, too tired perhaps. I'll get some rest and start working tomorrow with what's left with the guide and school's project.

Sorry, see you back later.

id, nil, pointers, messages, dynamic binding...

I dedicated some hours to read the ObjC guide by Apple.

Extremely interesting and in fact addictive. Since I don't have that much spare time I read only the Objects part. I'm missing classes and I'll finish Chapter 1.

A glimpse of what I've read:

Every object is of type id
id anObject;

nil is a null object with an id value of 0

[anObject aMethodInside] <- this stands for a message being sent to object anObject (receiver) telling that aMethodInside(message) has to be applied.

Regarding to parameters being sent inside the message for specific behavior. Suppose it's a rectangle object called myRec and a method inside it called setWidth.

[myRect setWidth:20.0];

Do you see the colon? Well that separates the values from the method. If you are wondering how to send more than just one obligatory param, this is the answer:

[myRect setOriginX: 30.0 y: 50.0];

And if we have a method which receives optional params? Perhaps a method that returns an array?

[receiver makeGroup:group, memberOne, memberTwo, memberThree];

As you can see makeGroup implementation inside the object could be the declaration of a group array that is being filled with three elements at runtime.

Dynamic binding is pretty useful because it handles polymorphism within methods. This happens because method implementation is different among objects but the method can be named the same. Therefore at runtime the behavior is not the same and results are exclusive for each object.

Fair enough, that's it for now. I'll study some more for my tomorrow's midterm.

Thanks!

edit: blog says 1:33am and as of my writing its 3:50am. I'll take a look where to change my time zone.

mini and display

Hey !

Lots of updates as of now. Not as much as the coffee I've drunk.

mini is working with 2gb without a glimpse. Excellent piece of hardware. The failures are still at the office since the person that validates the invoices for changing the dimms was not available. We'll see what happens tomorrow (in few hours).

As I've been staring the display for more than 6 hours I've noticed that there is one dead pixel. We've lost him.

Tomorrow I have mid-term and I'm really not that prepared but I can handle it wisely.

Wednesday, June 25, 2008

Happy again

Mac Mini is working flawlessly now.

The problem was the RAM memory. Wouldn't know why since they are Supertalent. Anyways, as of now I'm working with 1gb since I had to send the failures to warranty hoping to get 'em back by today.

I've been reading and it seems that the mini can handle up to 3gb unofficially.

RAM issues perhaps?

Hey!

I couln't get back yesterday. I rendered my 'lil mini useless. It's having some problems with RAM memory I guess. A friend of mine told me today that perhaps it's the temperature the mini reaches. Today I'll be replacing RAM memory and perhaps use it without the cover.

Objective-C kickoff delayed

Tuesday, June 24, 2008

First post and main objective

Tried to insert some javascript but didn't go well. Security reasons perhaps?
Let's start with the first complain, shall we?


Themes...lack of themes. Why in earth are there so few themes? I liked this one since I didn't like any other. It was a matter of themes discarding 'till one showed up.

Next, main purpose.

Not my life nor my hobbies, my passion. I'll be posting updates of how my Objective-C learning process is going and some screencasts of my work. Perhaps not as neat as you'd like 'em to be since they'll be live recording.

That's it for now. I'll be back later tonight for my first Obj-C related post.