threadss.h
-----------
#import <Foundation/Foundation.h>
@interface threadss : NSObject {
BOOL m_bRunThread;
int a,b,c;
}
-(void)startThread;
-(void)insert;
-(void)display;
@end
threadss.m
------------
import "threadss.h"
@implementation threadss
-(void)startThread
{
m_bRunThread = YES;
NSOperationQueue* queue = [[NSOperationQueue alloc]init];
//NSInvocationOperation* operation = [[NSInvocationOperation alloc]initWithTarget:self selector:@selector(display) object:nil];
//[queue addOperation:operation];
[[self insert] performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:YES];
[queue release];
//[operation release];
}
-(void)insert
{
NSLog(@"Into The Insert Event!!");
a=10;
b=20;
c = a + b;
}
-(void)display
{
NSLog(@"Into the display method");
NSLog(@"The value od c is:%d",c);
}
@end
main.m
-------
#import <Foundation/Foundation.h>
#import "threadss.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
threadss* thread = [[threadss alloc]init];
[thread startThread];
[pool drain];
return 0;
}
error:
------
void value not ignored as it ought to be
threadss.h ———– #import <Foundation/Foundation.h> @interface threadss : NSObject { BOOL m_bRunThread; int a,b,c; }
Share
Your problem comes from here:
[self insert]has a void return type, so you can’t use it as the receiver.I think you meant to write: