0

I am looking for a solution to add a nil object to and existing Mappable Model so I can use it for my Placeholder.

here is the model:

class PortfolioModel : Mappable {
    
    var photoUrl : String?
    var portfolioId : Int!
    
    required init?(map: Map) {
        
    }
    
    func mapping(map: Map) {
        photoUrl <- map["photoUrl"]
        portfolioId <- map["portfolioId"]
    }
}

in another class in my ViewController I have this:

var portfolioList : [PortfolioModel]?

1 Answer 1

1

You can mark the list item as optional to be able to add nil item to it.

var portfolioList : [PortfolioModel?]?
Sign up to request clarification or add additional context in comments.

6 Comments

did that already, still won't work, "self.photographerPortfolioURLList.append(nil)" this is the code I am using.
What is photographerPortfolioURLList?
its an array of [PortfolioModel]
is it [PortfolioModel?] or [PortfolioModel]
its [PortfolioModel?]? as you said above. I've handled it in a different way tho, I have added the String URLs inside of an Array of String and did the thing.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.