algorithm - LinkedList in Objective C will object be released? -


i making delete method in linked list in objective c. want delete node in list, however, in delete code, set "head" element's "next" node deleted's "next". cause node deleted not freed memory? if so, how fix?

the list node follows

@interface listnode : nsobject @property (nonatomic, assign) int data; @property (nonatomic, strong) listnode* next; @end 

the code delete below.

-(bool)deleteelementwithhead:(listnode*)headnode andnodetodelete:(listnode*)deletenode{      if (!head || !deletenode) {         return false;     }     listnode *element = head;      if (deletenode == head) {         listnode *temp;     temp = element.next;     head = nil;     head = temp;     return true;     }      while (element) {         if (element.next == deletenode) {             element.next = deletenode.next;//set pointer element node delete's "next" property points next 1 in list             deletenode = nil;             return true;         }         element = element.next;     }      return false; } 


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo