I get an error with setPropertyToFetch
.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray initWithObjects:count:]: attempt to insert nil object at objects[0]'
code:
NSString *str;
str = [NSString stringWithFormat:@"Event%d", variable];
NSString *value = [NSString stringWithFormat:@"values%d", vari];
TermometrAppDelegate *app;
app = (TermometrAppDelegate *)[UIApplication sharedApplication].delegate;
NSFetchRequest *fetchRequests = [[NSFetchRequest alloc] init];
NSEntityDescription *entit = [NSEntityDescription entityForName:str inManagedObjectContext:app.managedObjectContext];
[fetchRequests setEntity:entit] ;
[fetchRequests setReturnsDistinctResults:YES];
NSDictionary *entityProperties = [entit propertiesByName];
[fetchRequests setPropertiesToFetch :[NSArray arrayWithObject:[entityProperties objectForKey:value]]];
NSError *error;
fetchedObject = [app.managedObjectContext executeFetchRequest:fetchRequests error:&error];
NSManagedObject *fetched ;
printf("\n%d", [fetchedObject count]);
if ([fetchedObject count]==0)
{ for (int h=0;h<31;h++){ NSManagedObject *Event = [NSEntityDescription insertNewObjectForEntityForName:str inManagedObjectContext:app.managedObjectContext];
[Event setValue:[NSNumber numberWithInt:buf4[v+h]] forKey:value]; [app.managedObjectContext save:nil] ;}}
else {fetched=[fetchedObject objectAtIndex:0];
if([[fetched valueForKey:value] intValue]==0) {
for (int h=0;h<31;h++){ [[fetchedObject objectAtIndex:h] setValue:[NSNumber numberWithInt:buf4[v+h]] forKey:value];}
}
else{ printf("\n%d", buf4[v]);
for (int h=0;h<31;h++){ fetched=[fetchedObject objectAtIndex:h];
int plus=[[fetched valueForKey:value] intValue];
plus=(plus+buf4[v+h])/2;
[[fetchedObject objectAtIndex:h] setValue:[NSNumber numberWithInt:plus] forKey:value];}
}
}
[fetchRequests release];
[fetchedObject release];
** I forgot Create Enitity7 ... Entity64 hysterics - 2 week on problem to fetch attributes in entity.
I think you need to do programming language where each word - a common literary word - which means the command assembler. In any case, you need to strive for the programming language as the language of pure mathematics and the spoken language. That the language was as free as a spoken language, objectiv programming puts us in jail **