Curnelious Curnelious - 3 months ago 9
Swift Question

Init a UIView costume class with some data?

Right now my UIView class looks like this :

class CostumFlowViewCell: UIView {
override init (frame : CGRect)

super.init(frame : frame)


convenience init () {

required init(coder aDecoder: NSCoder) {
fatalError("This class does not support NSCoding")

I would like to be able to send it some array when I initialise it, so right now for example, I add it with :

let cell: CostumFlowViewCell= CostumFlowViewCell(frame:CGRectMake(0,0,0,0)

How would I init it with some
? (inside the cell class , and when I add it)


You can add an initializer like this:

init(anArray: NSArray)
    super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
    //do something with anArray

If you want the ability to init with an array and a frame, you can do so:

init(anArray: NSArray, frame: CGRect)
    super.init(frame: frame)
    //do something with anArray