0

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);
Hagelin
  • 16,440
  • 5
  • 29
  • 37
Gustavo
  • 785
  • 1
  • 12
  • 31

1 Answers1

3

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.

KingofBliss
  • 15,055
  • 6
  • 50
  • 72
  • Thanks this solve the problem, code: int identi; [data getBytes:&identi length:4]; NSLog(@"identificador: %i",identi); – Gustavo May 20 '11 at 09:25