Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4611650
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:17:47+00:00 2026-05-22T01:17:47+00:00

If I call a method in Objective-C with an argument and releasing the argument

  • 0

If I call a method in Objective-C with an argument and releasing the argument afterwords.

id argumentI = [Object new]; 
[ classA method1: argumentI ];
[ argumentI release ];

Then I know the argument is released AFTER method1 is finished, because the lines are processed linear.
BUT when I call the method in a background thread:

[ NSThread detachNewThreadSelector:@selector(method1) toTarget:self withObject:argumentI ];
[ argumentI release ];

And then the main thread releases the object, WHILE the background job uses the argument for something
(With the acceptance, that the retainCount would be 1 before the method is called).
Could I get an Error, because of the use of a Zombie (use of an object, that is already deallocated)?

The question is:

Do the methods call retain on an object that is an argument? Or do I need to call retain at the beginning of the method, if it is like the problem above?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:17:48+00:00Added an answer on May 22, 2026 at 1:17 am

    from the documentation of detachNewThreadSelector:toTarget:withObject:

    The objects aTarget and anArgument are retained during the execution of the detached thread, then released.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The objective is to call a method which does it's thing then returns a
I'm new to Objective-C and iPhone SDK development. I want to call a method
I'm using Objective-C, and I don't know how to create and call a method
Can I intercept a method call in Objective-C? How? Edit: Mark Powell 's answer
You can use a standard dot notation or a method call in Objective-C to
What is the normal behavior in Objective-C if you call a method on an
This is an objective-c question. I would like to call a method in an
I need to call a method that accepts a stream argument. The method loads
How do I call the -finalize method in Objective-C for garbage collection?
In Objective-C 2.0, is it possible to make a method where the argument is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.