I am getting the following error:

I can’t seem what is wrong with my code. Here’s some code in my AHInstagramImageData
-(id)initWithData:(NSDictionary *)data
{
self = [super init];
if (!self) {
return nil;
}
for (NSDictionary * comment in imgCmt){
AHInstagramImageComment * instagramImgComment = [[AHInstagramImageComment alloc] initWithData:comment];
[comments insertObject:instagramImgComment atIndex:0];
[instagramImgComment release];
}
}
and then on the AHInstagramImageComment I have:
-(id)initWithData:(NSDictionary *)data
{
self = [super init];
if (!self) {
return nil;
}
[self calculateCommentsHeight];
return self;
}
- (void) calculateCommentsHeight
{
NSString *combinedComment = [NSString stringWithFormat:@"%@ %@", self.username, self.text];
CGFloat desiredHeight = [combinedComment sizeWithFont:[UIFont fontWithName:@"HelveticaNeue" size:14] constrainedToSize:CGSizeMake(kCommentsMaxWidth, CGFLOAT_MAX) lineBreakMode:UILineBreakModeClip].height;
if (desiredHeight >= 50){
commentHeight_ = desiredHeight;
} else {
commentHeight_ = 50;
}
commentHeight_ += kTimestampMaxHeight;
commentHeight_ += 5;
}
So essentialy I had initializing the AHInstagramImageData in a background queue:
[weakSelf.backgroundQueue_ addOperationWithBlock:^{
NSArray *arr = [response valueForKey:@"data"];
int startingIndex = [[AHImageDataSource sharedDataSource] count];
for (NSDictionary * data in arr){
AHInstagramImageData * imgData = [[AHInstagramImageData alloc] initWithData:data];
}
}];
Is any of these wrong ?
I had a problem similiar to this before. There is currently a bug which prevents
[NSString sizeWithFont:]and[NSString drawInRect:]to run on background threads, or viaNSOperations.See this link:
Bug in UIKit string drawing method?
You have a few options:
sizeWithFont:withNSOperations.Set max operation count on your
NSOperationQueueto 1:[queue setMaxConcurrentOperations:1];Use Core Text and
NSAttributedStrings, which have their own “sizeWithFont” method:CTFramesetterSuggestFrameSizeWithConstraints[NSOperationQueue mainQueue];to run operations on the main thread.