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

  • SEARCH
  • Home
  • 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 6575709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:25:17+00:00 2026-05-25T15:25:17+00:00

[NSThread detachNewThreadSelector:@selector(addressLocation:) toTarget:self withObject:parameter]; [self addressLocation:parameter]; Should these two statements do the same thing?

  • 0
[NSThread detachNewThreadSelector:@selector(addressLocation:) toTarget:self withObject:parameter];

[self addressLocation:parameter];

Should these two statements do the same thing? Because one of them (the second one) gives me an accurate result, and the other consistently gives me a random location off the coast of Africa. From what I have read, they should both do the same thing; execute addressLocation with the argument ‘parameter.’ The only difference is the thread, but it is accessing a global volatile variable, so that shouldn’t matter, should it?

  • 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-25T15:25:17+00:00Added an answer on May 25, 2026 at 3:25 pm

    Threads are much more complicated than that. When you call detachNewThreadSelector, you are creating a new thread, but there’s no simple way for you to know when that call completes. It could complete before the next line of code in the calling thread or many seconds later.

    If you create the thread first, you can then use performSelector:onThread:withObject:waitUntilDone and you should get the same result as if you used [self addressLocation:parameter]. That won’t do you a lot of good though because your main thread will be doing nothing while you wait for the result.

    There are lots of ways to get data back from a thread — I like to call performSelectorOnMainThread from the secondary thread to send the data back to the main thread, for example.

    I would read up on Grand Central Dispatch to see if it suits your needs.

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

Sidebar

Related Questions

What is the differences between these two? [NSThread detachNewThreadSelector:@selector(method) toTarget:self withObject:nil]; [self performSelectorInBackground:@selector(method) withObject:nil];
Currently I'm using NSThread to cache images in another thread. [NSThread detachNewThreadSelector:@selector(cacheImage:) toTarget:self withObject:image];
I'm creating a new thread like this: [NSThread detachNewThreadSelector: @selector(myMethod:) toTarget:self withObject:filePath]; and in
I have implemented following in my application. for(i=0;!stopThroughButtons && i<totalMovements;i++){ [NSThread detachNewThreadSelector:@selector(moveNeedle) toTarget:self withObject:nil];
My application crashes on this line [NSThread detachNewThreadSelector: @selector(getJSON:) toTarget:self withObject:nil]; Here is how
i m using this on uitableviewcell's didselectrow method [NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil]; it works
i.e., I am creating a new thread like this: [NSThread detachNewThreadSelector:@selector(doSomething) toTarget:self withObject:nil]; will
I have a Thread called 10 times: [NSThread detachNewThreadSelector:@selector(workInBackground:) toTarget:self withObject:sendArray]; This is the
For the method: [NSThread detachNewThreadSelector:@selector(method:) toTarget:self withObject:(id)SELECTOR]; How do I pass in a @selector?
I' m calling doSaveItems: like [NSThread detachNewThreadSelector:@selector(doSaveItems:) toTarget:self withObject:aObject]; doSaveItems: method has a code

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.