0
最好用一個例子來解釋的一部分:在我AudioItem.h如何創建和分配一個C緩衝區作爲客觀的C級
#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;
}
上面的代碼看起來很像this一個,但我得到一個BAD_EXEC_ERROR ..怎麼來的?我想使用C緩衝區而不是一些NSMutableData或任何B/C的原因我嘗試使用NSMutableData,我覺得它會減慢我的實時應用程序