Edit AllPages

@implementation aClass

myClass *pointer = NULL;


Use an General/NSMutableArray.

I think you need to explain what you want to do in words. What the above refers to is that classes are objects. You can store them in an array and send the class object an alloc message to create new instances. But I can’t see why you’d want to set a global variable pointer like that.

If you’re looking for a construct like General/CeePlusPlus’s array constructor, you’re not going to find it in General/ObjC. You’ll have to loop through and create each individual member of the array. Although in normal Cocoa General/DesignPatterns, it’s not too common that you need to do this. (Or you could use an alternative binding like the General/JavaBridge or General/RubyCocoa, but those are always painful for entirely different reasons.)

Also, by convention, General/ObjC classes start with capital letters (General/NSObject, General/WebView, General/NXConstantString, etc.; not nsObject, webView and nxConstantString). It’s not mandatory like in General/RubyLanguage, but it’s as close to mandatory as you can get without being there.



@interface Vector : General/NSObject { float x,y,z; }


@implementation Controller

Vector *pointer = NULL;

I dont know the exact count of the vectors until i’ve scanned the file. I can write Vector *pointer[1000]; in my Controller.h, but if aNumber is smaller than 1000 it is waste of space.

Is this clear enough?


Yes. First of all, I’d just like to reiterate that you would probably be better off using the [[NSMutableArray class that comes with Cocoa.

@interface Controller : General/NSObject { General/NSMutableArray *vectorArray; } //Whatever else… @end

@implementation Controller

However, if you want to create a dynamically sized C array, you can do it with calloc (a variant of malloc, the memory-allocation function). You will need to free() the memory that you got from calloc when you’re done with it.

@implementation Controller

Vector **pointer = NULL; // It’s an array of pointers, hence the pointer-to-pointer