Hi again Harold,
The code sample I mentioned above is used at class definition time. Is there is something I am missing here? Here is how the full code segment should look like:
...
SCClassDefinition *sampleClassDef = [SCClassDefinition definitionWithEntityName:@"Sample"
withManagedObjectContext:managedObjectContext
withPropertyNames:[NSArray arrayWithObjects:@"propA", @"propB", nil]];
SCPropertyDefinition *propADef = [sampleClassDef propertyDefinitionWithName:@"propA"];
propADef.attributes = [SCTextFieldAttributes attributesWithPlaceholder:@"placeholder for propA"];
SCPropertyDefinition *propBDef = [sampleClassDef propertyDefinitionWithName:@"propB"];
propBDef.attributes = [SCTextFieldAttributes attributesWithPlaceholder:@"placeholder for propB"];
...
The problem with creating an additional SCClassDefinition initializer with the "withPlaceHolders" parameter (as you suggested) is an architectural one: not all class properties are necessarily of type text field. This is why we designed each property type with its own unique attributes.
Having said that, if you wish, you can create a new SCClassDefinition category with the following method:
// Note: the following code assumes propertyNames.count equals placeholders.count
+ (id)definitionWithEntityName:(NSString *)entityName
withManagedObjectContext:(NSManagedObjectContext *)context
withPropertyNames:(NSArray *)propertyNames
withPlaceholders:(NSArray *)placeholders
{
SCClassDefinition *classDef = [[[[self class] alloc]
initWithEntityName:entityName
withManagedObjectContext:context
withPropertyNames:propertyNames] autorelease];
for(int i=0; i<classDef.propertyDefinitionCount; i++)
{
SCPropertyDefinition *propertyDef = [classDef propertyDefinitionAtIndex:i];
if(propertyDef.type == SCPropertyTypeTextField)
{
propertyDef.attributes = [SCTextFieldAttributes attributesWithPlaceholder:[placeholders objectAtIndex:i]];
}
}
return classDef;
}