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

javascript - IndexedDB error: Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned -

amazon web services - When using Cognito credentials with AWS in a browser (javascript), keep getting "missing credentials" error -

c# - How to set the datatextfield value instead of the value on a drop down list? -