2016-06-06 3 views
-4
var frameColorInfo = [String:UIColor]() 
frameColorInfo["frameColor"] = logs.frameColor 
frameColorInfo["matColor"] = logs.matColor 

// To store frame Color things 
NSNotificationCenter.defaultCenter().postNotificationName("FrameColorThings", object:frameColorInfo) 

let frameColor:[UIColor] 
let matColor:[UIColor] 

frameColor: [UIDeviceRGBColorSpace 0.92549 0.92549 0.92549 1] 
matColor: [UIDeviceRGBColorSpace 0.92549 0.92549 0.92549 1] 

ich den Fehler bekam:Farbe Property akzeptieren nicht in Swift

Cannot assign value of type [UIColor] to type UIColor?

+6

'logs.frameColor' wahrscheinlich ein Array ist und kein' UIColor'. Aktualisieren Sie Ihre Frage mit relevanten Informationen – Shubhank

+0

@Subhank: Ich versuche, in Farbe in FrameColorInfo Array – kumar

+0

zu speichern aktualisieren Sie Ihre Frage mit wie FrameColor in seiner Quelldatei erklärt wird – Shubhank

Antwort

0

Kommentar- Kommentare, wenn Sie Arrays verwenden. Objekt als Benutzer Informationen nicht

var frameColorInfo = [String:UIColor]() 
frameColorInfo["frameColor"] = logs.frameColor//.first 
frameColorInfo["matColor"] = logs.matColor//.first 
NSNotificationCenter.defaultCenter().postNotificationName("FrameSizeThings", object: nil, userInfo: frameColorInfo) 
0

Sie die frameColor definiert haben verwenden und matColor als Array von [UIColor], die ich denke, ist einfach ein logischer Fehler von Ihrer Seite.

[String:UIColor] erwartet das Element UIColor anstelle eines Arrays.

Versuchen Sie es Erklärung

let frameColor:UIColor? 
let matColor:UIColor? 

verändern und dann in Ihrem Code verwenden

var frameColorInfo = [String:UIColor]() 
// do optionally checking if you want here 
frameColorInfo["frameColor"] = logs.frameColor! 
frameColorInfo["matColor"] = logs.matColor! 
Verwandte Themen