【发布时间】:2011-03-08 16:34:03
【问题描述】:
我想知道你们中是否有人可以帮助解决这个问题。下面的代码尝试在 char *path 中确定并包含的路径位置访问音频文件“4sSweepReverse.wav”。这段代码在模拟器上运行完全没问题,但是在iphone上运行就不行了?
//print out the file path
NSLog(@"FilePath: ");
NSLog(filePath);
//Cast filePath from NSString, to Char array pointer. Needed to get reference to audio file.
const char *path = [filePath cStringUsingEncoding:[NSString defaultCStringEncoding]];
//get a ref to the audio file, need one to open it
CFURLRef audioFileURL = CFURLCreateFromFileSystemRepresentation (NULL, (const UInt8 *) path, strlen (path), false);
//open the audio file
OSStatus result = AudioFileOpenURL (audioFileURL, 0x03, kAudioFileWAVEType, &mAudioFile);
//were there any errors reading? if so deal with them first
if (result != noErr) {
NSLog([NSString stringWithFormat:@"Could not open file: %s", filePath]);
packetCount = -1;
}
我知道文件中包含的路径是正确的。模拟器上的路径是
/Users/sam2/Library/Application Support/iPhone Simulator/4.2/Applications/A355770A-6942-4E1F-BB8D-8A1B1906B42C/audioRecorder.app/4sSweepReverse.wav
iPhone 上的路径是
/var/mobile/Applications/2273E045-0A63-439E-A6AC-FD85CD30F7F2/audioRecorder.app/4sSweepReverse.wav
但是当调试在 iPhone 上运行的应用程序时,我得到 -43 错误(或找不到文件)?
如果有人可以提供帮助,那就太棒了! 山姆
【问题讨论】:
标签: ios4 resources ios-simulator