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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:07:14+00:00 2026-05-19T11:07:14+00:00

Header : @interface CodeTest : NSObject { BOOL cancelThread; } -(void) testCode; -(void) stopRunning;

  • 0

Header :

@interface CodeTest : NSObject {
BOOL cancelThread;
}

-(void) testCode;
-(void) stopRunning;
-(void) startRunning;

@property (assign) BOOL cancelThread;
@end

Implementation :

-(void)stopRunning{
    self.cancelThread = YES;
}

-(void)startRunning{
    self.cancelThread = NO;

    [NSThread detachNewThreadSelector:@selector(testCode) toTarget:self withObject:nil];

}
-(void)testCode{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSLog(@"STARTED");
    /* Std C99 code */
    while( conditions ){
            if(self.cancelThread){
                 conditions = NO;
            }
            ...
            ...
    }
    /* end of C code */
    [pool release];
}

As you can see, it tires to execute testCode on a separate thread and using the cancelThread BOOL as a stop execution flag in the separate thread.

I have the following issue :

  • The compiler signals that self.cancelThread in the middle of the std c code is not valid (self is not defined). I think, it tries to interpret that statement as c code but this is obj-c.

There is something missing ?

UPDATE : It’s not related to missing {}’s as one of you suggested… The code works perfectly without the if(self.cancelThread){ conditions = NO; }.

  • 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-19T11:07:15+00:00Added an answer on May 19, 2026 at 11:07 am

    -[CodeTest setCancelThread:]: unrecognized selector.

    Means that you don’t have a setter defined for the cancelThread property. You’re missing

    @synthesize cancelThread;
    

    (in your @implementation section)

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

Sidebar

Related Questions

What is the nce between accessing a property via propertyname versus self.propertyname in objective-c?
I have to design a Font class that will have multiple implementations spanning platforms
I'm trying to use a UITextField as an output for a simple encryption. The
In my grid class I have the constructor: - (id) init { if (
How can I overwrite the initWithRootViewController method in a UINavigationController? The only methods generated
I am using a Nib as a template for several buttons. It seemed to
I am trying to create an iphone application that reads a json feed and
Is there any difference in where we define private instance variables? As I understand
Suppose you have an UITextView and you would like to set the delegate of
When I click on any of the toobar buttons, I get a : Terminating

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.