iOS:我收到一条错误消息“请求的属性表达式的地址”

时间:2018-06-27 09:49:45

标签: ios objective-c xcode pointers memory

我对代码行有疑问

memset(&array->objects[array->count] & memmove(&array->objects[objectIndex + 1UL] 

这是信息的全部代码:

if(!((array != NULL) && (array->objects != NULL) && (objectIndex <= array->count) && (newObject != NULL))) { [newObject autorelease]; return; }
  if((array->count + 1UL) >= array->capacity) {
    id *newObjects = NULL;
    if((newObjects = (id *)realloc(array->objects, sizeof(id) * (array->capacity + 16UL))) == NULL) { [NSException raise:NSMallocException format:@"Unable to resize objects array."]; }
      array->objects = *newObjects;
    array->capacity += 16UL;
    memset(&array->objects[array->count], 0, sizeof(id) * (array->capacity - array->count));
  }
  array->count++;
  if((objectIndex + 1UL) < array->count) { memmove(&array->objects[objectIndex + 1UL], &array->objects[objectIndex], sizeof(id) * ((array->count - 1UL) - objectIndex)); array->objects[objectIndex] = NULL; }
  array->objects[objectIndex] = newObject;

我真的不知道这个问题...

谢谢。

1 个答案:

答案 0 :(得分:0)

似乎在抱怨您试图获取指向作为类属性的对象的地址指针。在某种程度上,Objective C会尽量避免使用其属性和对象来避免使用C语言。我建议将数据从您的对象复制到某种类型的C结构中,然后使用该结构进行复制。