Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTom Coomer
1,331 PointsAdding textfield entries to an array
I would like to be able to add what the user has entered into a textfield, into an array. I would like the array to store all of the words that the user has entered. However I would also like to assign the number of times the user has entered that word in the array. I'd like it as an action from a button. How would I do this? Thanks!
1 Answer
Mike Gabriel
8,402 PointsI'm not sure I fully understand the order you would like to accomplish but you would setup an IBAction
for the button that fires addObject:
to the NSMutableArray
.
As for counting duplicates in the array you could store all of your objects from the array into an NSCountedSet
and then use countForObject:
Rashii Henry
16,433 PointsRashii Henry
16,433 PointsMike, have you created any ios applications before?
Rashii Henry
16,433 PointsRashii Henry
16,433 PointsMike, have you created any ios applications before?
Mike Gabriel
8,402 PointsMike Gabriel
8,402 PointsYes, I have two live in the App Store and one no longer under development.
Rashii Henry
16,433 PointsRashii Henry
16,433 Pointsdo you mind if i check them out? and do you mind if i ask how long have you been involved into development?