Reputation: 263
I'm trying to pass an array objects
to another view and i'm getting the following error:
Type Clipboard has no member
objects
this is the code I'm using to pass it:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
var Clipboard = segue.destinationViewController as! ClipBoard
var selectedIndexPath = tableView.indexPathForSelectedRow!
ClipBoard.objects = objects[selectedIndexPath.row]
}
I'm not sure if it makes a difference, but I'm using "self" with objects just before hand to pull from CloudKit
.
Upvotes: 0
Views: 128
Reputation: 285250
Do not use variable names with the same name as the type.
Declare always variables starting with a lowercase letter to avoid that confusion.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
var clipboard = segue.destinationViewController as! ClipBoard
var selectedIndexPath = tableView.indexPathForSelectedRow!
clipboard.objects = objects[selectedIndexPath.row]
}
Edit: And there is a typo : ClipBoard
vs. Clipboard
Upvotes: 2
Reputation: 669
What's happening is that you created a variable with the same name os your class.
When you do this:
ClipBoard.objects = objects[selectedIndexPath.row]
The compiler thinks that you are setting a value to a static variable in your class called ClipBoard.
The solution is to change the variable name to lowercase 'c'. Ex.: clipBoard
Upvotes: 1