I'm trying to get all the attributes for an entity and then determine their type - I know I can do something on this line:
if(![[thisAttribute attributeValueClassName] isKindOfClass:[NSString class]]) {
but how do I check for a BOOL, Float or Integer?
Here's my code so far:
//get the attributes for this entity - we need to parse the dictionary of data we want to store and convert its contents from NSStrings to whatever type the entity requires
NSEntityDescription* entity = [NSEntityDescription entityForName:strEntityName inManagedObjectContext:myMOC];
NSDictionary* dictAttributes = [entity attributesByName];
for(NSString* strThisKey in dictAttributes) {
NSAttributeDescription* thisAttribute = [dictAttributes objectForKey:strThisKey];
NSString* strAttributeType = [thisAttribute attributeValueClassName];
//look for a match in the data keys (the dict we passed) with the entity keys
for(NSString* strDataKey in dictDataToStore) {
//found
if ([strDataKey isEqualToString:strThisKey]) {
if(![strAttributeType isEqualToString:@"NSString"]) {
//check for whatever else (@"NSDate", @"NSNumber", etc.)
}
}
}
}
OK, I misunderstood what was being returned to me from NSAttributeDescription, I edited the code and essentially answered my question. Hope this helps someone else out.