Record sounds using a two-dimensional array
i'd开发者_StackOverflow中文版 like to record sounds played by tapping with a two dimensional array using the time and the sound id. is there any code example anywhere? thanx blacksheep
The code could look a bit like this:
@interface Recorder : NSObject
{
    NSMutableArray *times;
    NSMutableArray *samples;
}
@end
@implementation Recorder
- (id) init
{
    [super init];
    times = [[NSMutableArray alloc] init];
    samples = [[NSMutableArray alloc] init];
    return self;
}
- (void) recordSound: (id) someSound
{
    CFAbsoluteTime now = CFAbsoluteTimeGetCurrent();
    NSNumber *wrappedTime = [NSNumber numberWithDouble:now];
    [times addObject:wrappedTime];
    [samples addObject:someSound];
}
@end
Now you’ll have the sample times in the times array and samples in the samples array. You could create a two-dimensional array to hold the data, but this looks easier.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论