PDA

View Full Version : NSArray confusion for ObjC++ newbie


GreatBigBore
2006.05.10, 08:49 AM
Can anyone tell me why this code fails at runtime with EXC_BAD_ACCESS:

NSArray* propertyIDs =
[[NSArray alloc] initWithObjects:
(id)kAudioFilePropertyFileFormat, (id)kAudioFilePropertyDataFormat,
(id)kAudioFilePropertyAudioDataPacketCount, nil];

Am I doing something inappropriate with NSArray?

Taxxodium
2006.05.10, 09:27 AM
You need to add objects as in subclasses of NSObject, not int or enumerators or whatever.

In your case use a normal C array like int myArray[100]; or use an NSArray with NSNumbers (each NSNumber representing one of those kAudioFileProperty things).