CBRManagedObjectFormViewController 0.1.2

CBRManagedObjectFormViewController 0.1.2

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2014年12月

Oliver Letterer 维护。



CBRManagedObjectFormViewController 是一个 UITableViewController 子类,用于创建和编辑托管对象。

用法

以下是一个示例实体的示例

@interface SLEntity1 : NSManagedObject

@property (nonatomic, strong) NSNumber *dummyBool;

@property (nonatomic, strong) NSNumber *booleanValue;
@property (nonatomic, strong) NSString *stringValue;
@property (nonatomic, strong) NSDate *dateValue;

@property (nonatomic, strong) SLEntity2 *toOneRelation;
@property (nonatomic, strong) NSSet *toManyRelation;

@end

设置和配置 CBRManagedObjectFormViewController

CBRManagedObjectFormViewController *viewController = [[CBRManagedObjectFormViewController alloc] initWithEntity:self.entity editingType:CBRManagedObjectFormViewControllerEditingTypeCreate];

/*
setup property mapping, keys are the attributes of the entity
and values their human readable representation which will be displayed to to user
*/
viewController.propertyMapping = @{
  @"booleanValue": NSLocalizedString(@"BOOL", @""),
  @"stringValue": NSLocalizedString(@"String", @""),
  @"dateValue": NSLocalizedString(@"Date", @""),
  @"dummyBool": NSLocalizedString(@"dummy", @""),
};

// setup completion handler
[self.viewController setCompletionHandler:^(BOOL didSaveEntity) {
  // called when done, dismiss view controller here
}];

数据显示在 CBRManagedObjectFormViewController.sections 中组织

@interface CBRManagedObjectFormViewControllerSection : NSObject <NSCopying>

+ (instancetype)staticSectionWithProperties:(NSArray *)properties;

+ (instancetype)staticSectionWithEnumValue:(NSArray *)enumValues humanReadableOptions:(NSArray *)humanReadableOptions forAttribute:(NSString *)attribute;

+ (instancetype)dynamicSectionWithRelationship:(NSString *)relationship
                      fetchedResultsController:(NSFetchedResultsController *)fetchedResultsController
                                   formatBlock:(NSString *(^)(id entity))formatBlock;

@end

安装

作者

Oliver Letterer, [email protected]

许可证

CBRManagedObjectFormViewController 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。