Ios const void类型的操作数,其中需要arihmetic或指针类型
为什么会出现错误: 如果类型为const void,则操作数,其中算术或指针类型需要到以下行: //在文件中的特定位置插入数据Ios const void类型的操作数,其中需要arihmetic或指针类型,ios,filestream,iostream,streamwriter,Ios,Filestream,Iostream,Streamwriter,为什么会出现错误: 如果类型为const void,则操作数,其中算术或指针类型需要到以下行: //在文件中的特定位置插入数据 NSData *chunk = chunkContainer; // some data NSUInteger insertPoint = chunkNo*512; // get the insertion point // // make sure the file exists, if it does, do the followi
NSData *chunk = chunkContainer; // some data
NSUInteger insertPoint = chunkNo*512; // get the insertion point //
// make sure the file exists, if it does, do the following //
NSData *oldData = [NSData dataWithContentsOfFile:filePath];
// error checking would be nice... if (oldData) ... blah //
NSOutputStream *stream = [[NSOutputStream alloc] initToFileAtPath:filePath append:NO];
[stream open];
[stream write:(uint8_t *)[oldData bytes] maxLength:insertPoint]; // write the old data up to the insertion point //
[stream write:(uint8_t *)[chunk bytes] maxLength:[chunk length]]; // write the new data //
//THE NEXT LINE IS THE LINE I AM GEETING THE ERROR AT
[stream write:(uint8_t *)[oldData bytes][insertPoint] maxLength:([oldData length] - insertionPoint)]; // write the rest of old data at the end of the file //
[stream close];
((uint8_t*)[oldData bytes])+插入点如何??为什么+?它现在显示错误:预期的标识符+
是指针算术。它应该会起作用。问题解决了。我将查看此方法是否适用于在文件中插入值