开发者

Objective C: member variables and arrays

开发者 https://www.devze.com 2023-03-08 06:14 出处:网络
i have this variables (int and double-array) .h-File 开发者_C百科@interface MyCLass : NSObject { int myInt;

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

精彩评论

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