I have a UIPickerView
that gets its data from an array that is defined in
friends = [NSArray arrayWithObjects: @"jim", @"joe", @"anne", nil];
I have a button under the picker that is supposed to add new friends to the picker.
When the button is pressed a UIAlertController
pops up and the user can enter the new friends name. I can save the text as a string but I can't add it to the array. I've also tried using NSMutableArray
's.
I'm new to this so all input would be great. I've looked at similar questions for help but nothing has worked.
Thanks!
Ok so I will try to explain this:
You declare a
NSMutbleArray
, you can't expect to use aNSArray
because is not mutable, and you need to modify the content.Then you declare dataSource of UIPickerView:
So, then you present your UIAlertController, in this case I will dismiss it in the
Return
of theTextView
.This is more or less what you can do, I was the most specific I could be because you said you are a begginer.
Hope it Helps.