Thursday, September 29, 2011

Memory Clean Up for Link List in Objective-C

I have been working on trying to get the memory leaks vanish in for this
project and this is the approach i took, i don't know if it is
the right way to go or not. I created another function that traverse
through the list and delete all the remaining node before i delete the
actual List object. I know we have another function that searches the
list for a specified node to delete, but this other function i created
doesn't care what type of a node is in the List it wipes out every
node remaining in the list. But the tricky is you have to store the
current node into a temporary node, so that when you move on to the
next node thats when you delete whats behind, otherwise if you don't
do that then you will be trying to delete the current node causing the
current iteration of the List to break.

-(void) gabageCollector
{
Loop (through the while p is not == null)
save p into a temporary pointer;
assign p to the next pointer;
then release the temporary pointer;

}

The after setting up the function, then i call it like this in main

//go through the list and delete all remaining nodes
[newList gabageCollector];
//delete the List object
[newList release];

I don't know whether this is the right way to go but
thats the approach i took..

So long and stay thirst my friends........

Wednesday, September 28, 2011

Doubly Link List in Objective-C

I spent most of my weekend working on the doubly link list in objective-c. To be honest this project got me going as far as link lists are concern. I did the delete node function, i got done with that then, i started working on the sorting aspect of the list which i finished yesterday. At first I started imagining how i wanted to code this in my head and then tried to code it, and it did not work so well. So i decided to go back to the basics, by basics i mean drawing the link list on the paper and try to simulate the deletion of a node. I came up with 4 scenarios that could happen when trying to delete a node from a list. Then i followed the same procedures i drew on the paper and lord and behold there it was, and i know every programmer knows the feeling when you get stuff to work.

The four scenarios i check for of what could happen when deleting a node are:
1: if we found the node and it is in the middle of two nodes.
2: if we found the node and it is at the beginning of the list.
3: if we found the node and it is at the end of the list.
4: if we found the node and it is the only node in the list.

I don't know maybe there are more scenarios but these are the only ones i could possibly think of when i was doing my drawing simulation of a doubly link list. Overall this project taught me a lot of things on the aspect of a Link List and when you get stuck is is always good o go back to basics.

Till next time, so long stay tuned and thirst my friends.



Thursday, September 22, 2011

Objective-C LinkList

I have spent sometime testing my small chunks of code in Objective-C following some sample code from the book, just to get familiar with the language. After gaining a little bit of knowledge but a little bit enough, i started working on the Double Linked list in Objective-C. So far i have gotten all my classes set up and finally after hours of struggle i had a breakthrough inserting Nodes to the front of the list and printing it out. I first started with just inserting integers from 1 to 5, then after that worked then i added a char data type to the Node for the letter alphabet.

I am taking every precaution with this, it may seem simple to others but i got to take turtle steps (type one line of code compile and run just to make sure it is not broken). So far things are sinking in and i am hopping to get used to the syntax of Objective-C in no time, as they say if you practice you are perfecting your skills. I am hoping by weekend to get all the insert functions (insertAtBack, insertInMiddle) done and the delete function done.

so-long and stay thirst my friends..

Wednesday, September 14, 2011

Iphone Apps dev

With the mobile Apps on demand i thought to myself why not learn how to develop one for myself or develop for those in need of mobile Apps, maybe a combination of both. I believe possibilities are endless and steaks are high, you have to create cutting edge Apps that everyone would like to have, so i am willing to learn from anyone.

So with that said, i am currently working getting the basics of Objective-C and the working environment of X-code just to get familiar with the development process in a simplest way. I have been following small examples from the book "Programming in Objective-C" just to get familiar with the syntax.

It took me sometime to get the environment setup and getting it to work correctly and setting up the workspace in P4 correctly looks easy but somewhat challenging if you don't follow the steps correctly, as far as i am concern, it looked even harder than creating my first iphone App. The bottom line is it is part of learning and that is why there is those who knows to teach things they know to those who don't like myself, and all i did is ask and the answer was right there. Thanks to those who helped me to get this to work, but there will be more questions to come. To those who are afraid of asking, my advice to you is there is no such things as stupid question(s). And to those who knows the answer to the question(s) please help, the more you help the more you become better understanding of the subject involved.

I will keep everyone posted on my progress, stay tuned.