Search code examples
iosobjective-cuitextviewiboutletcollection

Ios Iterate on IBOutletCollection TextView


I'm trying to iterate and show my array on my text view collection.

@property (strong, nonatomic) IBOutletCollection(UITextView) NSArray *myTextViewCollection;

But on the UI, only the last element in my array is available.

I iterate with :

    for (UITextView *textView in myTextViewCollection) {
        for (int i = 0; i < feeds.count; i++) {
           textView.text = [[feeds objectAtIndex:i] objectForKey:@"title"];
           textView.editable = false;
        }
     }

feeds is a NSMutableArray contening a list of NSMutableDictionnary object.

An idea ?


Solution

  • Should be like this:

    for (int i = 0; i < myTextViewCollection.count; i++) {
        UITextView * textView = myTextViewCollection[i];
        textView.text = [[feeds objectAtIndex:i] objectForKey:@"title"];
        textView.editable = false;
    }