开发者

Objective C: member variables and arrays

i have this variables (int and double-array)

.h-File

开发者_C百科@interface MyCLass : NSObject
{
 int myInt;
double paramStack[100];
}

@property (nonatomic, assign) int myInt;
//@property (nonatomic, assign) double paramStack; //<- ?

.m-File

@synthesise myInt;
//@synthesize paramStack; //<- ?

I want the int and the double-array-variable accessible from other classes via properties. For the int-var. it looks fine, but the array throws errors at .m-file (@synthsize) and at h.file (@property (nonatomic, assign) double paramStack).

How can i define "@property (nonatomic, assign) double paramStack;" as a double-array?

Thanks


Make the property with a pointer:

@property(nonatomic, assign) double *paramStack;

You can just use it like this:

NSLog(@"%f", self.paramStack[20]);

This is mainly because an array cannot be returned, but a pointer can. I.E. this getter would be impossible and that's why you cannot create an array property:

- (double[100])paramStack;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜