ftp.nice.ch/peanuts/GeneralData/Usenet/news/1991/CSNProg-91.tar.gz#/comp-sys-next-programmer/1991/Dec/Help-with-simple-program

This is Help-with-simple-program in view mode; [Up]


Date: Sun 19-Dec-1991 18:35:37 From: arun@ac.dal.ca Subject: Help with simple program Help with beginner Objective C Hi, I'm trying to learn Objective C from scratch. I'm already familiar with C. I've read through "Object oriented programming and Objective C" in NeXTstep Concepts, but it has no examples and is barely more than a reference. I think there's Objective C for other computers, so I should say I'm using a NeXT. I've tried to write a simple program from this meager documentation and have got it down to one compiler error. Could anyone explain what is wrong with my program? --------------------------------------- test.h: ------- /* A test of defining a simple class in Objective C */ /* This file must should be named test.h */ #import <objc/Object.h> @interface AClass:Object /* Define new class inheriting properties of Object */ { id anObject; /* Define an object of AClass */ int x; /* A variable that is part of this class */ } - display; /* A method defined for this class */ - input:(int)x; - (int)output; @end ------- test.m: ------- @implementation AClass { int anInt; } - display { printf("The value is: %d\n", x); } - input:(int)anInt { x = anInt; } - (int)output { return(x); } -------------------------------------------------- And the error I'm getting is: test.m:10: inconsistent instance variable specification Until I can find and order some better books (hint: any recommendations?) I have to get by by studying Interface Builder and example code. Anyone have some simple examples? -George (on friends account)

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.