エンティティのすべての属性を取得してから、それらのタイプを決定しようとしています。この行で何かできることがわかっています。
if(![[thisAttribute attributeValueClassName] isKindOfClass:[NSString class]]) {
しかし、BOOL、Float、またはIntegerを確認するにはどうすればよいですか?
これまでの私のコードは次のとおりです。
//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、NSAttributeDescription から返されたものを誤解しました。コードを編集して、基本的に質問に答えました。これが他の誰かを助けることを願っています。