Error while loading from store.data


#1

Hi,
I have problem loading the saved data and the error is

2012-05-09 11:30:15.367 Homepwner[2796:fb03] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘Unacceptable type of value for attribute: property = “imageKey”; desired type = NSString; given type = UIImage; value = <UIImage: 0x91835e0>.’

the program is built successfully and run the the first time is ok. but after saving once and reload again, the above exception occurs. Already double the type of imageKey and it’s definitely “String” .
And try to re-do again in generating the new BNRItem.h & BNRItem.h as described in the book and the problem persists. I’m using Mac OS X version 10.7.3 and XCode 4.3.2 (4E2002).
Any help is much appreciated.
Regards,
Keung


#2

Without looking at your code, based on the error that you’re getting, it seems that you’re trying to assign imageKey (an NSString) an UIImage value.

I suggest you do a search throughout your project for the word ‘imageKey’ and focus at spots where you have ‘setImageKey’ and make sure you’re indeed assigning it an NSString and not a UIImage.

If that fails. Try resetting your simulator and compiling the app again, in the event that you made changes to your NSManagedObjectModel. If you change your model in any way, you’ll have to either migrate your data or remove your app and start fresh.


#3

Hi,
Still have the same error while removing the data model and re-input the entity and attributes according to the book. Using debugger, and find the code causing the exception is the
[[cell nameLabel] setText:[p itemName]]; in the function of - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath in itemViewController.m file. And using debugger to examine the BNRitem and found it’s perfectly ok in terms of the type (NSString)

2012-05-10 10:11:59.534 Homepwner[1778:fb03] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘Unacceptable type of value for attribute: property = “imageKey”; desired type = NSString; given type = UIImage; value = <UIImage: 0x6d729d0>.’
*** First throw call stack:
(0x12c5022 0x1776cd6 0x90a50 0x97c4a 0x90610 0x994bd 0x7c58 0x5325d 0x5183b 0x510a7 0x50c86 0x50b02 0x762a0 0x3533 0x398c54 0x3993ce 0x384cbd 0x3936f1 0x33cd21 0x12c6e42 0x299c679 0x29a6579 0x292b4f7 0x292d3f6 0x29ba160 0x2fce84 0x2fd767 0x30c183 0x30cc38 0x300634 0x1f80ef5 0x1299195 0x11fdff2 0x11fc8da 0x11fbd84 0x11fbc9b 0x2fcc65 0x2fe626 0x218d 0x20f5)
terminate called throwing an exceptionPrinting description of cell->nameLabel->_text:
Label
Printing description of p:
<BNRItem: 0x6d71150> (entity: BNRItem; id: 0x6d6fe70 x-coredata://B5D14B46-28F8-4446-B283-E2ECA6CC1BBF/BNRItem/p1 ; data: {
assetType = nil;
dateCreated = “2012-05-10 02:10:58 +0000”;
imageKey = “D0649388-7963-46A2-8C74-AA76BDC1A512”;
itemName = abc;
orderingValue = 1;
serialNumber = 123123;
thumbnail = nil;
thumbnailData = <89504e47 0d0a1a0a 0000000d 49484452 00000028 00000028 08060000 008cfeb8 6d000008 df494441 545809cd 59496f1c d711>;
valueInDollars = 30;
})