开发者

Setting animationImages array with UIImage's retrieved from Core Data store causes crash?

I cant locate in apple docs nor scanning the web for the solution to this problem.

I retrieve images (all ~70KB) from Core Data store using a fetch request with sort descriptor, make a mutable copy of the result and add the objects to a mutable array as follows...

NSFetchRequest *requestA = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"YearPhoto" inManagedObjectContext:managedObjectContext];
[requestA setEntity:entity];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[requestA setSortDescriptors:sortDescriptors];
[sortDescriptor release];
[sortDescriptors release];



NSError *error = nil;
NSMutableArray *mutableFetchResultsA = [[managedObjectContext executeFetchRequest:requestA error:&error] mutableCopy];
if (mutableFetchResultsA == nil) {

}

[self setImageArray:mutableFetchResultsA];
[mutableFetchResultsA release];
[requestA release];

I then setAnimationImages to this mutable array......

 self.theImageView.animationImages = [NSMutableArray arrayWithArray:imageArray];

I have checked using

NSLog(@"array's content:%@",imageArray);

Which confirms the array is not (null), I get multiple examples of below as expected....

"<YearPhoto: 0x16d0e0> (entity: YearPhoto; id: 0x16bc10 <x-coredata://2F4DDE20-855E-484A-AC8F-9F8E60F4162E/YearPhoto/p1> ; data: <fault>)",

When the app crashes, it faults on this line of code..

    self.theImageView.animationImages = [NSMutableArray arrayWithArray:imageArray];

Debugger throws out...

开发者_StackOverflow
2011-08-03 15:53:24.843 Year_book_app[2773:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[YearPhoto scale]: unrecognized selector sent to instance 0x190d60'

I have no idea why it fails. Can anyone shed any light on the matter. Am I seeding the animation images correctly?

I thank you in advance of any help!!

If you need any further details, please let me know.

DetartrateD.


Well the problem is you are sending objects that are type of YearPhoto instead of UIImage. self.theImageView.animationImages takes an array of UIImages as a valid value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜