Hello, i'm trying to get some basic custom class to work on objective-c but can t even get it to compile, yet i see no problems with it, am hoping for some help from these forums.
Ok first of all the idea:
simple app, 1 button on NIB, 1 AppControler with 1 (IBAction) method that is called when the button is pressed.
apart from that i have one custom class called test ( code comming after)
all this class does is have one method for printing some things to NSLog ( experimenting still with this).
Basically, what I want is to pass the AppController instance to the test class instance , so that from the test class ( threaded later on) call a method on the original object ( like for updating a gui).
THe idea is for me to get this working so that i can finish my twitter program. I made a simple twitter client, but when requests took too long, the gui freezed, i packaged the twittter "api" into a class, and made it work with the class ([twitter sendUpdate"works!"]) but I still had the "locking" of the gui.
So i want to make all the calls to twitter happen OFF main thread, i ve basically got it working for the update, but it did not work for the others that actually have a response that matters ( the response needs to be passed back to main thread so that I can update the gui) ,so the idea was to instantiate the twitter client passing the object a back-reference to the instantiator object..
I know i m not beeing to clear here, hope you can understand me anyway.
here is the sample code i m doing that does not compile :
AppController.h
AppController.m
test.h
test.m
I can t seem to find the "proper" way to do this, or have not been able to understand it...
any help on how this is usually done ( worker threads gathering data for the gui, these threads could instantiate objects etc...).
simple sample code is hard to find in this world of cocoa....
Ok first of all the idea:
simple app, 1 button on NIB, 1 AppControler with 1 (IBAction) method that is called when the button is pressed.
apart from that i have one custom class called test ( code comming after)
all this class does is have one method for printing some things to NSLog ( experimenting still with this).
Basically, what I want is to pass the AppController instance to the test class instance , so that from the test class ( threaded later on) call a method on the original object ( like for updating a gui).
THe idea is for me to get this working so that i can finish my twitter program. I made a simple twitter client, but when requests took too long, the gui freezed, i packaged the twittter "api" into a class, and made it work with the class ([twitter sendUpdate"works!"]) but I still had the "locking" of the gui.
So i want to make all the calls to twitter happen OFF main thread, i ve basically got it working for the update, but it did not work for the others that actually have a response that matters ( the response needs to be passed back to main thread so that I can update the gui) ,so the idea was to instantiate the twitter client passing the object a back-reference to the instantiator object..
I know i m not beeing to clear here, hope you can understand me anyway.
here is the sample code i m doing that does not compile :
AppController.h
Code:
#import <Cocoa/Cocoa.h>
#import "test.h"
@interface AppController : NSObject {
test *t;
}
-(IBAction) startVerga:(id)sender;
-(void)diecrap:(id)sender;
@end
Code:
#import "AppController.h"
@implementation AppController
-(void)awakeFromNib{
t = [[test alloc] initWithAppcontroller:self];
}
-(IBAction) startVerga:(id)sender
{
NSLog(@"Clicked on button");
}
-(void)diecrap:(id)sender
{
NSLog(@"llegue a crap!");
}
@end
Code:
#import <Cocoa/Cocoa.h>
#import "AppController.h"
@interface test : NSObject {
AppController *cont;
}
-(id)initWithAppcontroller:(AppController *)con;
@end
Code:
//
#import "test.h"
@implementation test
-(id) initWithAppcontroller:(AppController *)con
{
self=[super init];
cont = con;
return self;
}
@end
I can t seem to find the "proper" way to do this, or have not been able to understand it...
any help on how this is usually done ( worker threads gathering data for the gui, these threads could instantiate objects etc...).
simple sample code is hard to find in this world of cocoa....