Inherits from NSObject
Declared in TKEntity.h

Overview

This class represents a model that is created from the business object.

Properties

defaultGroup

The default property group that contains all properties without a group name.

@property (nonatomic, strong, readonly) TKEntityPropertyGroup *defaultGroup

Return Value

The default property group that contains all properties without a group name.

Declared In

TKEntity.h

groups

An array of TKEntityPropertyGroup objects.

@property (nonatomic, strong, readonly) NSArray *groups

Return Value

An array of TKEntityPropertyGroup objects.

Declared In

TKEntity.h

properties

An array of TKEntityProperty objects containing all the properties from the bisuness object.

@property (nonatomic, strong, readonly) NSArray *properties

Return Value

An array of TKEntityProperty objects containing all the properties from the bisuness object.

Declared In

TKEntity.h

sourceObject

The object from which a model will be created.

@property (nonatomic, weak) NSObject *sourceObject

Declared In

TKEntity.h

Class Methods

entityWithObject:

Instantiates a TKDataFormEntity with an object.

+ (instancetype)entityWithObject:(NSObject *)sourceObject

Parameters

sourceObject

The source object.

Declared In

TKEntity.h

Instance Methods

addGroup:

Adds a new group.

- (void)addGroup:(TKEntityPropertyGroup *)group

Parameters

group

The group instance.

Declared In

TKEntity.h

addGroupWithName:propertyNames:

Creates a new group with the specified name and properties.

- (TKEntityPropertyGroup *)addGroupWithName:(NSString *)name propertyNames:(NSArray *)propertyNames

Parameters

name

The group name.

propertyNames

a list with property names to include in the group.

Return Value

TKEntityPropertyGroup.

Declared In

TKEntity.h

commit

Commits the values of all properties to the bussiness object.

- (BOOL)commit

Declared In

TKEntity.h

groupAtIndex:

Returns the group at the specified index.

- (TKEntityPropertyGroup *)groupAtIndex:(NSUInteger)index

Parameters

index

The group index.

Return Value

TKEntityPropertyGroup.

Declared In

TKEntity.h

groupWithName:

Returns the group with the specified name.

- (TKEntityPropertyGroup *)groupWithName:(NSString *)groupName

Parameters

groupName

The group name.

Return Value

TKEntityPropertyGroup.

Declared In

TKEntity.h

initWithDataFromJSONResource:ofType:rootItemKeyPath:

Instantiates a TKEntity with data coming from a JSON formatted resource.

- (instancetype)initWithDataFromJSONResource:(NSString *)name ofType:(NSString *)type rootItemKeyPath:(NSString *)rootItemKeyPath

Parameters

name

The file name.

type

The file type.

rootItemKeyPath

The key path to an item in the JSON.

Declared In

TKEntity.h

initWithJSONFromURL:rootItemKeyPath:completion:

Instantiates a TKEntity which object will be created from JSON fetched from web service.

- (instancetype)initWithJSONFromURL:(NSString *)url rootItemKeyPath:(NSString *)rootItemKeyPath completion:(void ( ^ ) ( NSError *error ))completion

Parameters

url

The url where the JSON is located.

rootItemKeyPath

The key path to an item in the JSON.

completion

The block that is called after the data is loaded.

Declared In

TKEntity.h

initWithJSONString:rootItemKeyPath:

Instantiates a TKEntity with a JSON formatted string.

- (instancetype)initWithJSONString:(NSString *)str rootItemKeyPath:(NSString *)rootItemKeyPath

Parameters

str

The string containing JSON formatted data.

rootItemKeyPath

The key path to an item in the JSON.

Declared In

TKEntity.h

initWithObject:

Instantiates a TKEntity with an object.

- (instancetype)initWithObject:(NSObject *)sourceObject

Parameters

sourceObject

The source object.

Declared In

TKEntity.h

initWithObject:propertyNames:

Instantiates a TKEntity with an object and specific list of properties.

- (instancetype)initWithObject:(NSObject *)sourceObject propertyNames:(NSArray *)propertyNames

Parameters

sourceObject

The source object.

propertyNames

The propery names.

Declared In

TKEntity.h

insertGroup:atIndex:

Inserts a new group at the specified index.

- (void)insertGroup:(TKEntityPropertyGroup *)group atIndex:(NSUInteger)index

Parameters

group

The group instance.

index

The index where the group should be inserted.

Declared In

TKEntity.h

objectForKeyedSubscript:

The TKEntityProperty with the specified name.

- (TKEntityProperty *)objectForKeyedSubscript:(NSString *)propertyName

Parameters

propertyName

The name of the property that has to be returned.

Return Value

TKEntityProperty.

Declared In

TKEntity.h

propertyWithName:

The TKEntityProperty with the specified name.

- (TKEntityProperty *)propertyWithName:(NSString *)propertyName

Parameters

propertyName

The name of the property that has to be returned.

Return Value

TKEntityProperty.

Declared In

TKEntity.h

removeAllGroups

Removes all groups.

- (void)removeAllGroups

Declared In

TKEntity.h

removeGroup:

Removes the specified group.

- (void)removeGroup:(TKEntityPropertyGroup *)group

Parameters

group

The group to remove.

Declared In

TKEntity.h

removeGroupAtIndex:

Removes the group at the specified index.

- (void)removeGroupAtIndex:(NSUInteger)index

Parameters

index

The index of the group to remove.

Declared In

TKEntity.h

setSourceObject:withProperties:

Sets a new source object and creates its model.

- (void)setSourceObject:(NSObject *)sourceObject withProperties:(NSArray *)properties

Parameters

sourceObject

The object from which a model will be created.

properties

A list containing valid TKEntityProperty objects.

Declared In

TKEntity.h

setSourceObject:withPropertyNames:

Sets a new source object and creates its model.

- (void)setSourceObject:(NSObject *)sourceObject withPropertyNames:(NSArray *)propertyNames

Parameters

sourceObject

The object from which a model will be created.

propertyNames

The propery names.

Declared In

TKEntity.h

validate

Validates all properties and returns an array with property names that did not pass validation.

- (NSArray *)validate

Declared In

TKEntity.h

writeJSONToStream:

Writes JSON to an output stream.

- (NSError *)writeJSONToStream:(NSOutputStream *)outputStream

Parameters

outputStream

The output stream where the JSON will be written.

Return Value

Nil if the writing is successfull, otherwise NSError object.

Declared In

TKEntity.h

writeJSONToString

Creates a JSON formatted string from the entity’s properties.

- (NSString *)writeJSONToString

Return Value

JSON formatted string.

Declared In

TKEntity.h