objective-c: Do I have to release parameter objects or variable?

I was confused on this until I just realized that if the case is,


-(NSString*)name:(NSString*) _name {
    // I thought I need to do like [_name release];
    return _name;
}


So instead, the _name paramater object anyway is being reference, so ideally, the releasing of the object from memory is outside, i.e. from the callers perspective.

Like,

NSString *stupid = @"Johnny Bravo";
[name setName:stupid];
[stupid release];

or I can do autorelease anyway.

Comments

Popular posts from this blog

LVM: How to remove a volume using pvremove

Using Oracle 11g thru VirtualBox appliance in Mac OS X Lion

Use Shell Editor for Eclipse for editing bash, ksh, csh in Unix/Linux system