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

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -