paulrolfe / PARTagPicker

This pod provides a view controller for choosing and creating tags in the style of wordpress or tumblr.
MIT License
370 stars 48 forks source link

Change "chosen tags" via code #12

Closed gabrieltva closed 8 years ago

gabrieltva commented 8 years ago

Hi,

I want to change the variable "chosenTags" (ex: remove all or add all tags available).

But, when I setting a new NSMuttableArray, and in sequence, if I try select a new Tag the app's broke.

The code is like this:

- (IBAction)addAll:(id)sender {
    [self clearAll:nil];

    [_tagPicker setChosenTags:[self.allTags mutableCopy]];
}
- (IBAction)clearAll:(id)sender {
    self.preChosenTags = @[];
    [_tagPicker setChosenTags:[self.preChosenTags mutableCopy]];
}

I have to do something else?

Thanks.

paulrolfe commented 8 years ago

How does the app break, exactly?

I don't see anything in that snippet that would cause a crash.

gabrieltva commented 8 years ago

The error is this: NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array

When I touch to edit, the app crash (no tags is selected when I touch).

paulrolfe commented 8 years ago

I don't see anything thing in your sample code that would cause that issue. I'm merging in something soon that will make it somewhat easier though. I noticed a separate issue where the available tags weren't resetting correctly when I gave this a try -- no crash though.