James Knight
James Knight

Reputation: 21

Changes in array Swift 2

I have updated to swift 2 and the migration tool has not been able to update my arrays. Here is where I am getting the errors:

        actionArray.addObject(SKAction.moveTo(CGPointMake(position, -alien.size.height), duration: NSTimeInterval(duration)))

        actionArray.addObject(SKAction.removeFromParent())
        actionArray2.addObject(SKAction.moveTo(CGPointMake(position, -alienAzul.size.height), duration: NSTimeInterval(duration)))

        actionArray2.addObject(SKAction.removeFromParent())

This is what it says:

Value of type '[SKAction]' has no member 'addObject'

Upvotes: 0

Views: 343

Answers (2)

adolfosrs
adolfosrs

Reputation: 9389

Best practices for Swift is to use Arrays as follows:

Define your array variable as

var actionArray: [SKAction]!

Instantiate it:

actionArray = [SKAction]()

Add objects to it with:

actionArray.append(sKAction)

Upvotes: 1

MickaCapi
MickaCapi

Reputation: 131

You have to use append(newElement: Element)

Upvotes: 0

Related Questions