Home save array of object contain image in my iOS app
Reply: 1

save array of object contain image in my iOS app

Atta Ahmed
1#
Atta Ahmed Published in 2017-11-14 18:27:50Z

I want to save array of users , every user has name ,phone ,image and video , what is the best way to do that ?

Ios
memtarhan
2#
memtarhan Reply to 2017-11-14 19:04:05Z

I'd have a photo URL and a video URL instead of media. Those URLs can be references from your server or database. A Sample code could be:

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) 
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.333677 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO