【发布时间】:2012-05-07 01:46:25
【问题描述】:
如何在构造函数中设置指向 C 数组的指针?
@implementation NSBufferedInputStream {
char *buffer;
int bufferSize;
}
- (id)initWithFileAtPath:(NSString *)path
{
self = [super initWithFileAtPath:path];
if (self) {
bufferSize = 100;
buffer = char[bufferSize]; // ERROR: Expected expression
}
}
@end
【问题讨论】:
-
乍一看,我会说它是因为 c 不支持动态数组而不使用 malloc 或类似的东西。
标签: objective-c c arrays pointers