I am populating a UITableView with Person objects stored in Core Data. Each person has a firstName, lastName, and image. The image is a relationship to a separate Image entity which has a property called data of type Transformable. This is where I am storing the image associated with each Person.
I am populating the table with:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PersonCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
Person *person = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSMutableString *nameString = [[NSMutableString alloc] init];
if (person.firstName)
{
[nameString appendString:[NSString stringWithFormat:@"%@ ",person.firstName]];
}
if (person.lastName)
{
[nameString appendString:person.lastName];
}
cell.textLabel.text = nameString;
UIImage *image = person.image.data;
cell.imageView.image = image;
return cell;
}
When I run my app, I get the error:
: CGAffineTransformInvert: singular matrix.
once for each item in the table or database.
if I comment out the line:
cell.imageView.image = image;
the error goes away.
Any ideas? This is the first time I’ve stored binary data in Core Data, maybe its not transforming right?
This is how I”m storing the image:
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
self.person = [Person personWithImage:image inManagedObjectContext:self.context];
and
+ (Person *)personWithImage: (UIImage *)image inManagedObjectContext:(NSManagedObjectContext *)context
{
Image *newImage = [NSEntityDescription insertNewObjectForEntityForName:@"Image" inManagedObjectContext:context];
newImage.data = image;
Person *newPerson = [NSEntityDescription insertNewObjectForEntityForName:@"Person"
inManagedObjectContext:context];
newPerson.image = newImage;
return newPerson;
}
thanks,
Gerry
OK, I figured this out by luck. my uitableview uses images in the cells, and i was putting the full size camera images in there, and of course ran into some memory issues. as soon as I started resizing the images to 960×640, that random CGAffineTransformInvert error went away!
I still don’t know why it was happening in the first place, but i guess it doesn’t really matter because its gone now.