Question

I´m getting an EXC_BAD_ACCESS when I trying to acces to the data, I suppose it is because I trying to acces to the internal data, but I don´t know How to solve this, the code:

//data->NSMutableData

int identi;

[data getBytes:&identi];
NSLog(@"identificador: %i",identi);
Was it helpful?

Solution

According to documentation,

Deprecated in Mac OS X v10.6. This method is unsafe because it could potentially cause buffer overruns. You should use getBytes:length: or getBytes:range: instead.

The method is,

- (void)getBytes:(void *)buffer

Parameters: buffer

A buffer into which to copy the receiver's data. The buffer must be at least length bytes.

You are trying to save the receiver data into identi, a int value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top