You could give your buttons different tags and use viewWithTag, but an NSArray might be a cleaner approach, faster, and there's no chance of two view objects having the same tag and potentially crashing your app.
Put all of your buttons in an NSArray. Then you can access a particular button by using the objectAtIndex: method of the array in your for loop.
I am having a lot of trouble with NSArray.I tried to generate a NSMutableArray
that will store the data permanently and I will be able to get the data frome everywhere in the code but i just wont do it.
We can't help you without more details. Post the code, describe the problem, did you get crashes? If so, post the crash log from the console, do you get compiler errors or warnings? If so, post the exact message and the line on which you get it. Does your code not do what you want? If so, what does it do and what did you expect it to do.
We can't help you without more details. Post the code, describe the problem, did you get crashes? If so, post the crash log from the console, do you get compiler errors or warnings? If so, post the exact message and the line on which you get it. Does your code not do what you want? If so, what does it do and what did you expect it to do.
Hi, thanks for the fast answer.
I can't post the code now because I and away from the mac computer.
but i can provide some info:
I need a vector ( array ) of random numbers 1 to 20 without duplicates.
so with the help from Duncan from this forum I creates a NSMutableArray wit numbers from 1 t 20. then I used a function to scramble the order of the numbers in the array. so far so good.
now I want to be able to save this array and to able to get the numbers by for loop. the problem is when I use an if statement all the data in the array is lost.
Is it possible to copy a Mutable array NSArray?
I tried to make the NSMutableArray to be a "global" but it ain't working.
If some one have an example of how to make Array to operate as global it will be grate.
yea you're definitely gonna need to post the code, you're doing something sketchy. Also, how did we get from buttons to randomly generated numbers in an array?
yea you're definitely gonna need to post the code, you're doing something sketchy. Also, how did we get from buttons to randomly generated numbers in an array?
it was just a small question that i thought that will solve the problem.
I will post the code tomorrow.