Parsing of m3u files in Objective-C for iPhone from file system or URL

无人久伴 提交于 2019-12-03 16:53:27

Just because you've changed the path doesn't mean that you've renamed/moved/copied an item, path is just a string. Use NSFileManager methods like

– moveItemAtURL:toURL:error: or

– moveItemAtPath:toPath:error:.

Also, NSString doesn't care about extension, so it's completely safe to read your m3u file to NSString, no need to rename it.

NSString *addPath = [[NSBundle mainBundle]  pathForResource:@"somefile" ofType:@"m3u" ];
if ([fileMgr fileExistsAtPath:addPath] ) {
    NSLog(@"Yes.We see the file");
    NSString *fileContents1 = [NSString stringWithContentsOfFile:addPath encoding:NSUTF8StringEncoding error:NULL];
    NSArray *lines1 = [fileContents1 componentsSeparatedByString:@"\n"];
    NSLog (@"%@",fileContents1);
    NSLog (@"%@",lines1);
}
else {
    NSLog(@"Nope there is no file");
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!