I have a code that removes an object from an NSCollectionView, but it only removes one item. In the NSArray ("array") the value is "2 4" which returns 2, 4. But when I run the code, it only removes "2" and not "4".
The Log:
Click here for the image of the NSLOG.
The Code
NSString* LibraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *plistPathSMSettings = [LibraryPath stringByAppendingString:stormarManagerSettingsPlistPath];
NSString *betasDef = [SMInAppCommunicationDEF stringByAppendingString:@"BETA App Id"];
NSString *indexOfApp = [Functions readDataFromPlist:plistPathSMSettings ForKey:betasDef];
if (!(indexOfApp == nil)) {
NSArray * array = [indexOfApp componentsSeparatedByString:@" "];
NSLog(@"Array: ", array);
int currentValue = 0;
for (int i = 0; i < [array count]; i++)
{
currentValue = [(NSNumber *)[array objectAtIndex:i] intValue];
NSLog(@"currentValue: %d", currentValue); // EXE_BAD_ACCESS
NSLog(@"x: %d", i);
[self.content removeObjectAtIndex:(currentValue)];
[self.collectionView setContent:self.content];
[self.collectionView reloadData];
NSLog(@"next: %d", currentValue); // EXE_BAD_ACCESS
}
}
else if (indexOfApp == nil) {
[self.collectionView setContent:self.content];
[self.collectionView reloadData];
}