最好用一个例子来解释:
在我的 AudioItem.h
#define ITEM_CAPACITY 100
typedef struct DataStruct {
void * content;
UInt32 size;
} DataStruct;
typedef DataStruct *DataStructRef;
@interface AudioItem : NSObject
{
DataStructRef data;
}
@property (assign, readwrite) DataStructRef data;
在 AudioItem.m @synthesize 数据中;
-(id)initWithID:(NSString *)itemID
{
self = [super init];
data->content = malloc(ITEM_CAPACITY);
return self;
}
上面的代码看起来很像这个,但是我得到一个 BAD_EXEC_ERROR.. 怎么会?我想使用 C 缓冲区而不是一些 NSMutableData 或任何 b/c 的原因我尝试过使用 NSMutableData 并且我觉得它减慢了我的实时应用程序