When i call this method code is crashing and throw the error like "setObjectForKey: key cannot be nil"
Please guide me....
Thanks! Here is my code:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSArray* groupKeyName = [self.groupsDict allKeysForObject:collectionView];
NSArray* groupList = self.groupedServiceInfoDict[groupKeyName[0]];
NSDictionary* dict = groupList[indexPath.item];
static NSString *CellIdentifier = @"GroupCell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
cell.layer.borderWidth = 1.0f;
cell.layer.borderColor = [UIColor colorWithRed:225/255.0f green:225/255.0f blue:225/255.0f alpha:1.0f].CGColor;
OnGoServiceCategories *serviceCategory = [self.groupedServiceInfoDict[@"grouplist"] objectAtIndex:indexPath.item];
UILabel* nameLabel = (UILabel*)[cell viewWithTag:2];
nameLabel.text = serviceCategory.Name;
NSString* imageUrl = [dict objectForKey:@"Image_URL"];
UIImage *image = [[CXResourceManager sharedInstance] imageForPath:imageUrl];
UIImageView* imageView = (UIImageView*)[cell viewWithTag:4];
if(!image)
{
[[OnGoDownloadManager sharedDownloadManager] downloadDataWithURLString:imageUrl
dataType:DATA_TYPE_BINARY finishBlock:^(OnGoDownloadData *downloadData){
if (downloadData.downloadStatus == DOWNLOAD_STATUS_SUCCESS)
{
UIImage *image = [UIImage imageWithData:downloadData.data];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[imageView setImage:image];
[[CXResourceManager sharedInstance] setImage:image forPath:imageUrl];
CGSize size = [image size];
CGFloat deltaWidth = size.width - imageView.frame.size.width;
CGFloat deltaHeight = size.height - imageView.frame.size.height;
NSValue* value = [self.sizesDict objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.item]];
CGSize defaultSize = [value CGSizeValue];
CGSize newSize;
newSize.height = defaultSize.height + deltaHeight;
newSize.width = defaultSize.width ;
[self.sizesDict setObject:[NSValue valueWithCGSize:newSize] forKey:[NSString stringWithFormat:@"%ld", (long)indexPath.item]];
[self.collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
}
}];
}
else
{
[imageView setImage:image];
}
return cell;
}
Aucun commentaire:
Enregistrer un commentaire