ios - 我在文档文件夹(沙盒)中有多首歌曲如何在 sqlite 中保存 Perticaluer colum

标签 ios objective-c sqlite

我正在录制声音并将其存储在沙箱中,并在下一个 View 中将声音名称和这首歌存储在 sqlite 中。我已经使用了 blob,但应用程序变得太慢了。所以我想将特定歌曲的沙盒路径存储在 sqlite 数据库中。

记录保存目的

- (void)saveRecordFile
{
    NSLog(@"play Record");
    if (audioPlayerRecord)
    {
        if (audioPlayerRecord.isPlaying) [audioPlayerRecord stop];
        else [audioPlayerRecord play];

        return;
    }

初始化播放 Audio Session

    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,    NSUserDomainMask, YES);
    NSString *recDir = [paths objectAtIndex:0];
    NSString *pathToSave = [recDir stringByAppendingPathComponent:[self dateString]];
    songUrl = [NSURL fileURLWithPath:pathToSave];

这里 songUrl 有所有歌曲如何存储在数据库中。

最佳答案

不要将文件路径转换为 ​​URL。将其作为路径。然后只需将路径字符串保存到您的数据库中。

如果您将 BLOB 设置为链接到数据库中其他实体的单独实体,则应该能够将 BLOB 保存到数据库中而不会降低速度。不要使 BLOB 成为记录的字段。它使记录太“沉重”。

关于ios - 我在文档文件夹(沙盒)中有多首歌曲如何在 sqlite 中保存 Perticaluer colum,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23911384/

相关文章:

ios - 在 IOS 中获取 CoreData

ios - Xcode 6 仪器卡住

ios - 取消本地通知后如何停止本地通知声音

ios sqlite3链接错误

ios - ipad 上的 SQLite3 问题。不断收到 'constraint failed' 错误

ios - 尝试将多个值附加到 Swift 字典中的同一个键

iphone - iOS 应用程序 - 如何每 60 秒检查一次服务器更新?

objective-c - 不允许在 swift 类中使用 Objective C 头文件中定义的 Constant。体系结构 armv7 的 undefined symbol

iphone - 获取两个位置之间的路线方向

Android Room 数据库查询不返回 id 列