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 8818863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:12:42+00:00 2026-06-14T05:12:42+00:00

If I have a custom method like this: – (void)myMethod:(id)myArgument { //do something with

  • 0

If I have a custom method like this:

- (void)myMethod:(id)myArgument 
{
      //do something with myArgument
}

is myArgument guaranteed to stick around for the execution of that method if i don’t take ownership of it?

EDIT
Let me elaborate further. Say i call this somewhere:

[self myMethod:_myIvar];

and then somewhere else, while myMethod is executing, someone calls this:

[_myIvar release];

does that effect the argument within myMethod?

END EDIT

Looking through documentation/sample code, i rarely see a [myArgument retain] or [myArgument copy] at the top of a custom method. So is it unnecessary?

Thanks!

  • 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-06-14T05:12:43+00:00Added an answer on June 14, 2026 at 5:12 am

    If myArgument is a valid object at the start of myMethod, and you do nothing to cause it to be deallocated or otherwise collected during the method, then yes, myArgument will still be a valid object at the end of the method.

    EDIT in response to question’s edit: let’s talk about object ownership in this case. When you’re passed myArgument as an argument to your function, you – in the context of myMethod – don’t declare an interest in the object by retaining or copying it. In such a situation, the only owners of the object exist outside myMethod.

    If the last owner of myArgument decides that it’s done with myArgument and releases it, then it’s entirely possible that myArgument goes away – there are no strong references to the object any more that would keep it around. It may be valid, depending on threading concerns, autorelease pools involved, and a whole host of other issues, but that’s a dangerous game to play. If there’s even a possibility that such a situation might happen, you should explicitly declare an interest in myArgument within myMethod, as recommended by the Memory Management Policy.

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

Sidebar

Related Questions

I have a UIViewController with a custom init method that looks like this: -
I have a custom listView. The main layout xml is something like this: <?xml
I have a custom UITableViewCell that I use like this: AppTableCell *cell = [tableView
I have a web service method where I would like to throw some custom
I have created a custom method that will return unique items, together with the
I have a custom class of type NSObject that contains a single NSMutableArray. This
I have custom assembly that is loaded on runtime. at this point i have
I have added a method on jQuery validator like this $.validator.addMethod( 'myEqual', function (value,
I have a custom validator method that will check an inputted zip code against
I have custom UIViewController which looks like this. @implementation UIViewControllerCustom - (id)init { self

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.