Reputation: 31
I'm trying to create an array within my swift class in Xcode 6 beta 4 but I get the following error:
Swift Compile Error 'Level1.Type' does not have a member named 'someInts'
Here is my code
import SpriteKit
class Level1: SKScene, SKPhysicsContactDelegate {
var someInts = [Int]()
var message = "someInts is of type [Int] with \(someInts.count) items."
}
Adding the same variable declarations into a Swift playground does not produce this error.
What am I doing wrong here?
I'm trying to create an array within my class that can hold objects of type Int
Regards
Upvotes: 3
Views: 590
Reputation: 130222
This issue is with the second variable. You can't assign a property a value that depends on another property inline. You can use a computed property though.
class Level1: SKScene, SKPhysicsContactDelegate {
var someInts = [Int]()
var message: String {
return "someInts is of type [Int] with \(someInts.count) items."
}
}
Upvotes: 3