Swift collections in unit tests -



Swift collections in unit tests -

i new swift , don't understand implicit type casting, have in unit test:

let protocols: anyobject? = nsbundle.mainbundle().infodictionary?["uisupportedexternalaccessoryprotocols"];

i need test protocols exists, array , contains "foo" , "bar".

i came solution:

let protocols: anyobject? = nsbundle.mainbundle().infodictionary?["uisupportedexternalaccessoryprotocols"]; if allow p = protocols as? [string] { xctasserttrue(contains(p, "foo")); xctasserttrue(contains(p, "bar")); } else { xctfail("uisupportedexternalaccessoryprotocols must array"); }

is there improve way handle it?

unit-testing swift

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

ubuntu - Bash Script to Check That Files Are Being Created -

Php operator `break` doesn't stop while -