kas-kad / AKTagsInputView

convenient input view for tags strings
Apache License 2.0
85 stars 20 forks source link

'-[AKTagTextFieldCell resetReadyForDeleteStatus]: unrecognized selector'... #18

Closed akhatmullin closed 9 years ago

akhatmullin commented 9 years ago

... fix

akhatmullin commented 9 years ago

Yes, Andrey. AKTagCell contain this method, but we have class 'AKTagTextFieldCell' and his superclass is 'UICollectionViewCell', not 'AKTagCell' I can repeat this bug and crash with fast entering tags.

image

kas-kad commented 9 years ago

I think there is a bug with wrong determined AKTagCell var. It should not reference to a textFieldCell

kas-kad commented 9 years ago

In other words the variable must refer on either nil or a tagCell. But not a textFieldCell for sure.

akhatmullin commented 9 years ago

"To be or not to be?" (c) :) But in line 127 in file AKTagInputView.m we get object 'lastTagCell' by method 'cellForItemAtIndexPath:indexPathForRow:inSection:' and this method returning to us object class 'AKTagTextFieldCell'

kas-kad commented 9 years ago

Yes, I think we should change the if statement:

if (self.selectedTags.count > 1){
        lastTagCell = (AKTagCell*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForRow:self.selectedTags.count-1 inSection:0]];
    }

so that we never make our lastTagCell to refer to the textfield cell

akhatmullin commented 9 years ago

I think this is not solution. We always have cell with textfield for input (1, 5, 5000 items in array 'selectedTags')

akhatmullin commented 9 years ago

In other way I see more dirthy solution - change base class for 'AKTagTextFieldCell' to 'AKTagCell'

kas-kad commented 9 years ago

I see no reason to inherit textField cell from TagCell. They are too different objects.

kas-kad commented 9 years ago

Oh nevermind my mistake about self.selectedTags.count.

akhatmullin commented 9 years ago

And at this point our ideas identical about base class for AKTagTextFieldCell :)

akhatmullin commented 9 years ago

Hmm! What you think about checking the class of lastTagCell ? if ([lastTagCell isKindOfClass:NSClassFromString(@"AKTagCell")]) { [lastTagCell resetReadyForDeleteStatus]; }

kas-kad commented 9 years ago

I'd prefer to fix a root of the problem. The bug appears because of fast tags entering. So we must check for the inconsistent state, that becomes possible in this particular tricky user behaviour. Checking the kindOfClass is another dirty workaround I my opinion. You can use it for some time, but I'm definitely going to fix the root of the problem.

kas-kad commented 9 years ago

I think the inconsistency becomes possible because of a time lag, that may exists before user tapped Return and the selectedTags gets new tag into (something about collection view animation, reloading and completion callbacks). Not sure. Need to check this.

kas-kad commented 9 years ago

check my comments in AKTagsListView -> - (void)addNewItemWithString:(NSString *)string completion:(void(^)(void))compeltion if you want some details

akhatmullin commented 9 years ago

You a right! My solutions is not pretty. :) Hope I help you with updating your beautiful tool for input tags.

akhatmullin commented 9 years ago

I see that more later. Thank you!