kas-kad / AKTagsInputView

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

NSInternalInconsistencyException when attempting to add tags in example #10

Closed kfateem closed 9 years ago

kfateem commented 10 years ago

Attempting to add tags in example results in an NSInternalInconsistencyException:

AKTagsInputViewExample[54660:22954455] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (6) must be equal to the number of items contained in that section before the update (7), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).' * First throw call stack: ( 0 CoreFoundation 0x000000010516c3f5 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000104e05bb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010516c25a +[NSException raise:format:arguments:] + 106 3 Foundation 0x0000000104a2328f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4 UIKit 0x0000000103cfdfb7 -[UICollectionView _endItemAnimations] + 12835 5 UIKit 0x0000000103d031f9 -[UICollectionView performBatchUpdates:completion:] + 390 6 AKTagsInputViewExample 0x00000001033d15c4 -[AKTagsLookup filterLookupWithPredicate:] + 260 7 AKTagsInputViewExample 0x00000001033cc489 -[AKTagsInputView addNewItemWithString:completion:] + 233 8 AKTagsInputViewExample 0x00000001033cbab7 -[AKTagsInputView tagsLookup:didSelectTag:] + 103 9 AKTagsInputViewExample 0x00000001033d18ec -[AKTagsLookup tagsListView:didSelectTag:atIndexPath:] + 236 10 AKTagsInputViewExample 0x00000001033c9180 -[AKTagsListView collectionView:didSelectItemAtIndexPath:] + 320 11 UIKit 0x0000000103d04929 -[UICollectionView

robertocolonello commented 9 years ago

there is a problem with the performBatchUpdates. You can change in AKTagsLookup.m

-(void)filterLookupWithPredicate:(NSPredicate )predicate { self.predicate = predicate; NSMutableArray filteredTags = [[self.tagsBase filteredArrayUsingPredicate:self.predicate] mutableCopy]; self.tagsView.selectedTags = filteredTags; [self.tagsView.collectionView reloadData]; [self.tagsView.collectionView layoutIfNeeded]; }

kas-kad commented 9 years ago

I have made some changes, resetting buggy PR's accepted by mistake. Also refreshed tag 1.0.1 - you can use the example project from that tagged commit (75d010e661dbe646e97b5c68101b35538445563b), note the issues list though