I start to use core data with ios 5. I have my product model :
Product.m :
#import "Product.h" @implementation Product @dynamic category_id; @dynamic label; @dynamic price; @end
Product.h :
#import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @interface Product : NSManagedObject @property (nonatomic, retain) NSString *category_id; @property (nonatomic, retain) NSString *label; @property (nonatomic, retain) NSString *price; @end
I try to parse an xml with a custom class using NSXMLParserDelegate. My xml looks like :
<section id="2"> <label>Animaux</label> <image>Images/Rayons/Bandeau/Animaux.png</image> <key>Images/Rayons/Bandeau/Animaux.png</key> <products> <Product id="21"> <category_id>Chat</category_id> <label>Aliments pour chat</label> <price>2.00</price> </Product> <Product id="1286"> <category_id>Chat</category_id> <label>Boite de paté</label> <price>0.00</price> </Product> </products> </sections>
When i have a balise Product, I build my model like this :
item = [[NSClassFromString(className) alloc] init];
And when i have a property as category_id, i do :
[item setValue:currentNodeContent forKey:elementName];
And i got the error :
CoreData: error: Failed to call designated initializer on NSManagedObject class 'Product'
Any idea?