Re: Simple scope check.
Re: Simple scope check.
- Subject: Re: Simple scope check.
- From: Sandro Noel <email@hidden>
- Date: Sat, 9 Dec 2006 19:59:08 -0500
Hank,
Many thanks for taking the time...
I did read the memory management Rules
But to a newcomer to cocoa, all this stuff together is quite a lot to
digest. :)
I'm from a Delphi / Java background... there is a lot of garbage
collection there in java and delphi releases it's objects when a
parent is released.
So memory management is quite "new" to me.
please excuse my newby questions.
and again thank you for taking the time to explain...
Sandro Noel.
On 9-Dec-06, at 7:49 PM, Hank Heijink wrote:
In this case, you're returning an autoreleased instance, so no
worries. The Memory Management Guide explains this in detail. If
you retain something and you don't release it, you'll end up with a
memory leak. It won't be released automatically.
On Dec 9, 2006, at 7:22 PM, Sandro Noel wrote:
and another question :)
if i retain an object when entering a function and i do not
release it, will it be released automatically?
after the function ends ?
in the example of this structure of function.
+ (NSNumber *)xxxxxNumber: (NSString *) input{
return [NSNumber numberWithInt: [encode uncodeInteger:input]];
}
There is really no space for me to release it before the return ...
Thank you
Sandro Noel.
On 9-Dec-06, at 7:18 PM, Sandro Noel wrote:
Oh and would it be absolutely wise for me to retain the input
value just in case
it is already auto-released somewhere else? and release it before
the function ends?
Sandro Noel .
On 9-Dec-06, at 7:14 PM, Sandro Noel wrote:
Greetings,
i was just wondering if Cocoa behaved like other languages
concerning variable scope.
i did search the documentation for variable scope but all i get
back is the references for Apple Scripts ...
so... in this function.
+ (NSString *)numberFizzle: (NSNumber *) input{
NSString *intToStr = [ [ [NSString alloc] stringWithFormat:@"%
d",[input intValue]] autorelease];
NSString *tempStr = [ [ [NSString alloc] stringWithFormat:@"i%d:
%d", [intToStr length], [input intValue]] autorelease];
NSLog(tempStr);
return tempStr;
}
so if Objective-C (cocoa) behaves like i think. there is no need
for me to autorealease anything that does not exit my function.
so fo example here, the intToStr variable will be automatically
killed at the end of the function
so i would not have to autorelease it... BUT tempStr will exit
the function therefor i should autorelease it just in case it is
not released by the user...
is that right ?
Thank you for your assistance !
Sandro Noel.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40gestosoft.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Hank Heijink
www.hankheijink.com
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden