我想保存一系列用户,每个用户都有姓名,电话,图片和视频,最好的方法是什么?
答案 0 :(得分:1)
我有照片网址和视频网址,而不是媒体。这些URL可以是来自服务器或数据库的引用。示例代码可以是:
class User {
var name: String?
var phone: Int?
var photoUrl: String?
var videoUrl: String?
init(name: String, phone: Int, photoUrl: String, videoUrl: String) {
self.name = name
self.phone = phone
self.photoUrl = photoUrl
self.videoUrl = videoUrl
}
}
var users = [User]()
let user1 = User(name: "Something", phone: 123456, photoUrl: "SomeUrl", videoUrl: "SomeUrl")
let user2 = User(name: "Something", phone: 123456987, photoUrl: "SomeUrl", videoUrl: "SomeUrl")
users.append(user1)
users.append(user2)
答案 1 :(得分:1)
尝试在您的应用或领域中使用核心数据:D