我在这里将值放入结构中:
[self createEntityWithX:20 andY:20 withType:0 withWidth:20 andLength:20 atSpeed:5];
...
...
-(void)createEntityWithX:(int)newEntityX andY:(int)newEntityY withType:(int)newEntityType withWidth:(int)newEntityWidth andLength:(int)newEntityLength atSpeed:(int)newEntitySpeed
{
Entity tmpEntity;
tmpEntity.entityX = newEntityX;
tmpEntity.entityY = newEntityY;
tmpEntity.entityLength = newEntityLength;
tmpEntity.entityWidth = newEntityWidth;
tmpEntity.entityType = newEntityType;
tmpEntity.entitySpeed = newEntitySpeed;
NSValue *tmp = [NSValue valueWithBytes:&tmpEntity objCType:@encode(struct Entity)];
[entityArray addObject:tmp];
}
-(Entity)retreiveEntityFromValue:(NSValue *)value
{
Entity entity1;
[value getValue:&entity1];
return entity1;
}
当我取回数据时,数据正在被加扰?我创建了实体:X:20 Y:20 Width:20 并返回 x:1712736 Y:0 Width:0? X 是完全随机的,但其余的保持为 0
我哪里出错了?