mardi 7 juillet 2015

swift os x array binary operator error compare with nil != if statement

I have declared an array of an array of tuples:

 var graphDetailsArray: [Array<(graphType: String,  columnLabel: String, columnColor: NSColor, columnHeight: CGFloat, columnNumber: Int)>] = []

a little later on in the function I check this array for nil before activating some code:

    if graphDetailsArray != nil {  //some code here

This is throwing up an error at build time with a "Binary operator '!=' cannot be applied to type Array<(graphType: String, columnLabel: String, columnColor: NSColor, columnHeight: CGFloat, columnNumber: Int)> and nil.

I have a tried a range of different syntaxes and can not get this to work.

Any assistance would be appreciated. How do I check for an empty array?

Is using "graphDetails.isEmpty" the same as checking for nil??

Aucun commentaire:

Enregistrer un commentaire