ios - Swift - Get list of countries -



ios - Swift - Get list of countries -

how can array countries names in swift? i've tried convert code had in objective-c, this:

if (!pickercountriesisshown) { nsmutablearray *countries = [nsmutablearray arraywithcapacity: [[nslocale isocountrycodes] count]]; (nsstring *countrycode in [nslocale isocountrycodes]) { nsstring *identifier = [nslocale localeidentifierfromcomponents: [nsdictionary dictionarywithobject: countrycode forkey: nslocalecountrycode]]; nsstring *country = [[nslocale currentlocale] displaynameforkey: nslocaleidentifier value: identifier]; [countries addobject: country]; }

and in swift can't pass here:

if (!countriespickershown) { var countries: nsmutablearray = nsmutablearray() countries = nsmutablearray.arraywithcapacity((nslocale.isocountrycodes).count) // here gives error. marks nslocale.isocountrycodes , .count

does of know this?

thanks

first of isocountrycodes requires argument parenthesis instead isocountrycodes(). second, dont need parenthesis around nslocale , isocountrycodes(). also, arraywithcapacity deprecated meaning removed language. working version of this

if (!countriespickershown) { var countries = nsmutablearray() countries = nsmutablearray(capacity: (nslocale.isocountrycodes().count)) }

ios arrays swift nslocale countries

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -