I'm trying to learn the basics of Obj C from "Learning Objective C 2.0 by Robert Clair"
I have an array of NSNumber objects that I write the Array into an NSData objects buffer. What I'd like to do is validate the NSNumber objects were written correctly using something like NSLog but I just get garbage when I attempt this.
Here is my Code :
int howManyBytes3 = 100;
NSMutableArray *myArray3 = [NSMutableArray array]; //Creates an empty NSArray
for (NSInteger i=0; i<50; i++)
{
[myArray3 addObject:[NSNumber numberWithInteger:i]];
}
NSLog(@"My Array 3 contains : %@", myArray3);
NSMutableData *myData3 = [NSMutableData dataWithBytesNoCopy:myArray3 length:howManyBytes3 freeWhenDone:NO];
NSLog(@"myData3 contains : %@", myData3);
and this is the output I get on console:
2018-09-16 13:24:39.396705+0100 Chapter9[12351:1341392] myData3 contains : <917f30a8 ffff1d00 00000000 00000000 30186200
01000000 00000000 44000000 33000000 32000000 00000000 00000000 00000000 00000000 01050610 00000010 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 6ad3364c> Program ended with exit code: 0
What am I doing wrong?
NSLog
in this case? Did it do anything wrong? – trungduc