ios - Swift: Storing pattern information and assigning it to pictures -


i have list of roughly 100 patterns, different shapes. example, 1 'arrow left, arrow down, arrow right'.

i looking way store information once random pattern has been selected, can loaded algorithm detects whether pattern user inputs same pattern has been loaded. problem here how store arrow/shapes in different patterns.

one way could done using enums, know. there object called pattern1 contains array of objects called arrowl, arrowu, arrowr, arrowd.

however i'm not sure how program kind of incidence, appreciate help. if use two or 3 examples demonstrate use of enum, grateful.

thank you, will

to store pattern, said, use array containing respective list of directions. let's have following directions:

enum direction {     case up, down, left, right } 

now can create array using directions:

var pattern : [direction] = [.up, .up, .left, .right] 

you can create array of patterns (or array of arrays of directions):

var patterns : [[direction]] = [     [.left, .right, .right],                          // pattern 0     [.up, .down, .up, .left, .right, .left],          // pattern 1     [.down, .down, .down, .down, .up, .down, .down]   // pattern 2 ] 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -