gpt4 book ai didi

ios - 构成应用程序数据模型的数组变量最好放在哪里?

转载 作者:行者123 更新时间:2023-11-28 07:24:49 24 4
gpt4 key购买 nike

我的名为“Thunder”的 iOS 应用程序越来越复杂,我想知道是否有我不知道的关于数据建模的最佳实践。我不知道在哪里存储我的数组变量。

现在的“Thunder”允许用户录制音频剪辑并将其发布到他们的时间线(主页)。

项目结构(https://github.com/makhfib/Thunder)

    Thunder
-- AppDelegate
-- TabBarViewController
-- Home
---- AudioClipViewController
---- AudioClipCell
---- HomeViewController
-- Record
---- RecordViewController
-- Library
---- LibraryViewController
-- DataModel
-- AudioPlayer
-- AudioClip
...

到目前为止,DataModel 保存了包含用户发布的音频剪辑的数组变量。但是,我要添加一个新功能:

Users will be able to add new playlists to their library.

这需要一个数组的数组。但我不知道是否应该继续将我的变量放在 DataModel 中。这个问题听起来可能很愚蠢,但请记住,我正在考虑 future 。我想知道当我的应用程序变胖时如何处理这种情况。

组成应用程序数据模型的数组变量最好放在哪里?为了做出最好的决定,我必须问自己什么?

最佳答案

您的数据模型有什么用?我认为您的模型应该与此类似:

struct UserInfo {
var playlists: [Playlist]
// MARK: Other content
}

struct Playlist {
var clips: [AudioClip]
// MARK: Other content
}

struct AudioClip {
// MARK: Content
}

使用这种模型更容易工作,或者保存在数据库中,例如领域或核心数据。

关于ios - 构成应用程序数据模型的数组变量最好放在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56912710/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com