It doesn't work!


#1

i bought cocoa programming for MAC OS X 4th edition and tried to do the first exercice (Random) of the book on chapter 2 and it doesn’t work (i’m using XCODE 6)

i have indeed an error when i declare the following code NSTextField *textField

here is my code :

[i]#import <Foundation/Foundation.h>

@interface RandomController : NSObject {
IBOutlet NSTextField *textField;
}

-(IBAction) seed:(id)sender;
-(IBAction) generate:(id)sender;

@end
[/i]

XCODE returns the following error

  • unknown type name NStextField
  • instance variable with ‘IBOutlet’ attribute must be an object type (invalid ‘int *’)

can i have an explanation ?
(forgive me for my english, i’m french :slight_smile: )


#2

Eureka !!

I understood why it didn’t work

I added the following instruction

#import <AppKit/AppKit.h>

after the #import <Foundation/Foundation.h> in my RandomController.h

Now it works !

[i]#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

@interface RandomController : NSObject {
IBOutlet NSTextField *textField;
}

-(IBAction) seed:(id)sender;
-(IBAction) generate:(id)sender;

@end
[/i]

thanks for your help folks :smiley: