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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:53:31+00:00 2026-05-13T16:53:31+00:00

I am passing an object to a secondary thread using the following code: (void)login:(id)sender

  • 0

I am passing an object to a secondary thread using the following code:

 (void)login:(id)sender
{
  platformMsgs_LoginRequest *loginRequest = [[[platformMsgs_LoginRequest alloc] init] autorelease];
//more code...
 [NSThread detachNewThreadSelector:@selector(sendLoginRequest:) toTarget:self withObject:loginRequest];
//more code...
}

- (void)sendLoginRequest:(platformMsgs_LoginRequest *)loginRequest
 {
 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 [loginRequest retain];
 NetSuiteBinding *binding = [NetSuiteServiceSvc NetSuiteBinding];
 NetSuiteBindingResponse *response = [binding loginUsingParameters:loginRequest      applicationInfo:nil partnerInfo:nil];
 [self performSelectorOnMainThread:@selector(loginOperationCompleted:)   withObject:response waitUntilDone:NO];
 [loginRequest release];
 [pool drain];
 }

My question is, is autorelease the right way to handle the release of this object?. Once it is passed to the secondary thread I retain it and release it when I no longer need it.

However is it possible that the autorelease, releases the object before the secondary thread has a chance to retain it?. Do I have to create an ivar for this?, so that I can release the object in the performSelectorOnMainThread?. I no longer need the object after the login so an ivar doesn’t seem like the right way to go. What is the best way to handle this?. Thank you.

-Oscar

  • 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-13T16:53:31+00:00Added an answer on May 13, 2026 at 4:53 pm

    The documentation for detachNewThreadSelector:toTarget:withObject: answers your question:

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

    So yes, you can autorelease the object or release it explicitly after calling detachNewThreadSelector. And you don’t have to retain the object in the secondary thread.

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

Sidebar

Related Questions

If I am passing an object to a method, why should I use the
I am trying to use a business object that I am passing to the
I am parsing XML with an XMLReader using a XMLReaderSettings object with the event
When you're passing variables through your site using GET requests, do you validate (regular
.NET XSLT engine allows passing objects to the XSLT processing engine through the AddExtensionObject
Passing an undimensioned array to the VB6's Ubound function will cause an error, so
I'm passing raw HTTP requests to an apache server (received by PHP). The request
I'm currently passing the pid on the command line to the child, but is
I'm passing a reference of a form to a class. Within this class I
I'm doing some Objective-C programming that involves parsing an NSXmlDocument and populating an objects

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.