objective c - Access an array according to a NSString's value -


this question has answer here:

in app user has twelve buttons available, , have defined twelve nsmutablearrays. if user clicks button one, app should count number of objects in comp1 array, or if user clicks button two, app should count number of objects in comp2 array, , on.

when user clicks button, save name of respective nsmutablearray in nsstring -- example, mystring = @"comp1". problem is, how "define" nsmutablearray name mystring?

i wish there method like: [nsmutablearray arraywithtitle:mystring].

create dictionary holds arrays. dictionary key title you're looking for.

for instance, insert button1's array dictionary, when want retrieve count use:

nsinteger count = [mydictionary[@"comp1"] count]; 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -