有陣時App 會用到一啲existing既file
例如有個static既file 叫做 fileName.ext
NSBundle *bundle = [NSBundle mainBundle]; //係app folder入面搵
NSURL *someFileURL = [bundle URLForResource:@"fileName" withExtension:@"ext"];
如果用NSString:
NSString *path = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"ext"];
如果係plist
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:someFileURL];
如果係wav
SystemSoundID soundID;
AudioServicesCreateSystemSoundID(
(__bridge CFURLRef)someFileURL, &soundID);
AudioServicesPlaySystemSound (soundID);
沒有留言:
張貼留言