AaronG
AaronG

Reputation: 522

How do I populate a NSMutableArray with UILabels?

I don't think I am creating this array of UILabels correctly.

If I put a breakpoint after this line of code, it shows that the array is empty.

 colorLabelArray = [[NSMutableArray alloc] initWithObjects:  greenLabel, orangeLabel, blackLabel,purpleLabel, yellowLabel, redLabel, blueLabel, whiteLabel, nil];

If I do the same thing with UIImages it works just fine. What am I missing?

Upvotes: 2

Views: 293

Answers (2)

RedBlueThing
RedBlueThing

Reputation: 42522

Your syntax is fine. I would check if greenLabel is nil?

Upvotes: 3

benzado
benzado

Reputation: 84308

Are you certain that none of the label objects are nil? Specifically, if greenLabel is nil, then initWithObjects: will ignore the rest of the argument list and return an empty array.

Upvotes: 5

Related Questions