• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple scope check.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple scope check.


  • Subject: Re: Simple scope check.
  • From: Sandro Noel <email@hidden>
  • Date: Sat, 9 Dec 2006 20:02:39 -0500

Good point,
i'll keep it in mind...

just a quick question, if i'm retaining an object from a thread and the thread is released while
i'm accessing/working with the object will the thread wait until i'm finished or will it be released, and the object live until i'm finished with it ?





Sandro.

On 9-Dec-06, at 7:54 PM, Michael Watson wrote:

As a note of completeness, it's not something you typically need to worry about when dealing with values passed in from the same thread. However, if your application is multithreaded, and the method will be dealing with input values from threads outside of the method's scope, it may be wise to retain the input values for the life of the method.


-- m-s

On 09 Dec, 2006, at 19:47, Hank Heijink wrote:

No. You don't own the input value, so it's not your responsibility.

On Dec 9, 2006, 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:
40bungie.org


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


  • Follow-Ups:
    • Re: Simple scope check.
      • From: "Philip Q" <email@hidden>
References: 
 >Simple scope check. (From: Sandro Noel <email@hidden>)
 >Re: Simple scope check. (From: Sandro Noel <email@hidden>)
 >Re: Simple scope check. (From: Hank Heijink <email@hidden>)
 >Re: Simple scope check. (From: Michael Watson <email@hidden>)

  • Prev by Date: Re: Simple scope check.
  • Next by Date: Re: Simple scope check.
  • Previous by thread: Re: Simple scope check.
  • Next by thread: Re: Simple scope check.
  • Index(es):
    • Date
    • Thread