ios - How to make a array of strings -



ios - How to make a array of strings -

two questions:

first question:

i want create arrays of strings this:

country[1]=norway; capital[1]=oslo;

country[2]=germany; capital[2]=berlin;

how write code? should simple, don't understand of explanations i've seen. guess want utilize nsarray, because don't want alter them! guess main question how declare array!

second question:

can utilize illustration capital[2] in button text? quiz , want 1 of options if country[2] given country.

/a noob

easiest way declare nsarray in obj-c this:

nsarray *countries = @[@"norway", @"germany"]; nsarray *capitals = @[@"oslo", @"berlin"];

you can access indexes later using [] notation:

[mybutton settitle:capitals[1] forstate:uicontrolstatenormal];

remember arrays in programming languages 0-indexed! means first element index 0, sec index 1 , forth

ios arrays string

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -