0

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'

1
  • Are u using NSMutableArray? Commented Dec 5, 2015 at 17:54

2 Answers 2

1

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)
Sign up to request clarification or add additional context in comments.

Comments

0

You have to use append(newElement: Element)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.