0
NSManagedObject의 하위 클래스를 초기화 할 수 있는지 알고 싶습니다. NSManagedObject의 하위 클래스 인 "Actualite"클래스가 있는데이 클래스를 초기화하려고 할 때 다음 오류가 발생합니다. "CoreData : 오류 : NSManagedObject 클래스 Actualite에서 지정된 초기화 프로그램을 호출하지 못했습니다."응용 프로그램이 충돌합니다. 이 메시지 "- [Actualite setTitre는 :] : 인식 할 수없는 선택기 0x8433be0 인스턴스로 전송"Init NSManagedObject 하위 클래스
여기 내 코드입니다 :
-(void) recupererActualites {
listeNouvellesActualites = [[NSMutableArray alloc] init];
// Convert the supplied URL string into a usable URL object
NSURL *url = [NSURL URLWithString:FACE06_RSS];
// Create a new rssParser object based on the TouchXML "CXMLDocument" class, this is the
// object that actually grabs and processes the RSS data
CXMLDocument *rssParser = [[CXMLDocument alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding options:0 error:nil];
// Create a new Array object to be used with the looping of the results from the rssParser
NSArray *resultNodes = NULL;
// Set the resultNodes Array to contain an object for every instance of an node in our RSS feed
resultNodes = [rssParser nodesForXPath:@"//item" error:nil];
NSMutableArray* tmp = [[NSMutableArray alloc] init];
for (CXMLElement* resultElement in resultNodes) {
// Create a temporary MutableDictionary to store the items fields in, which will eventually end up in blogEntries
NSMutableDictionary *blogItem = [[NSMutableDictionary alloc] init];
NSMutableArray* categories = [[NSMutableArray alloc] init];
// Create a counter variable as type "int"
int counter;
// Loop through the children of the current node
for(counter = 0; counter < [resultElement childCount]; counter++) {
// Add each field to the blogItem Dictionary with the node name as key and node value as the value
if([[[resultElement childAtIndex:counter] name] isEqual:@"category"])
[categories addObject:[[resultElement childAtIndex:counter] stringValue]];
else {
if ([[resultElement childAtIndex:counter] stringValue] != nil)
[blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];
else
[blogItem setObject:@"" forKey:[[resultElement childAtIndex:counter] name]];
}
}
Actualite* actu = [[Actualite alloc] init];
[blogItem setObject:categories forKey:@"categories"];
[actu initWithDictionnary:blogItem];
[tmp addObject:actu];
//[actu release];
[categories release];
[blogItem release];
}
listeNouvellesActualites = tmp;
[rssParser release];
resultNodes = nil;
// Stockage des actualités en local
[self stockerActualites];
}
그리고 Actualite 클래스의 모든 속성 설정 initWithDictionary 방법.
는 또한Actualite* actu = [[Actualite alloc] initWithEntity:[NSEntityDescription entityForName:@"Actualite" inManagedObjectContext:managedObjectContext] insertIntoManagedObjectContext:managedObjectContext];
및
Actualite* actu = (Actualite*)[NSEntityDescription entityForName:@"Actualite" inManagedObjectContext:managedObjectContext];
대신
Actualite* actu = [[Actualite alloc] init];
오류가 사라
을 시도했지만 응용 프로그램이 시점에서 멈 춥니 다. 나는 무엇을 할 수 있을지 모른다 ...누군가 이미이 문제가 있었습니까?
고맙습니다.