Ошибка: пустое значение не игнорируется, как должно быть - Цель C - PullRequest
0 голосов
/ 01 июня 2011
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

1 Ответ

4 голосов
/ 01 июня 2011

Ваша проблема возникает отсюда:

[[self insert] performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:YES];

[self insert] имеет тип возврата void, поэтому его нельзя использовать в качестве получателя.

Я думаю, что вы хотели написать:

[self insert];
[self performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:YES];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...