2014-09-03 33 views
1

在Xcode中6測試版7,我不能把一個的UIImage在AnyObject陣列:如何將UIImage放入AnyObject數組?

var objects = [pizzaImage.image, title, ingredients.text] 

錯誤: Cannot convert the expression's type 'Array' to type 'ArrayLiteralConvertible

在測試沒有問題,6

編輯 這是完整的代碼,嘗試了一切,但沒有運氣:

var objects = [pizzaImage.image!, title, ingredients.text!]] 
var act = UIActivityViewController(activityItems: objects, applicationActivities: nil) 
self.presentViewController(act, animated: true, completion: nil) 
+1

它與此有關嗎? http://stackoverflow.com/questions/25649875/xcode-6-beta7-nsdictionary-to-swift – Paulw11 2014-09-03 21:15:41

+0

解包圖像在這種情況下沒有效果,對不起 – Enlil 2014-09-03 21:22:52

+0

@MarcelloCat:'ingredients.text'也必須解包。 – 2014-09-03 21:32:20

回答

1

解決:

var objects = [pizzaImage.image!, title!, ingredients.text]] 
var act = UIActivityViewController(activityItems: objects, applicationActivities: nil) 
self.presentViewController(act, animated: true, completion: nil) 

,但如果你把只有標題和文本字段的編譯器有什麼可抱怨:

var objects = [title, ingredients.text] 

爲什麼? 這是真的不清楚......