Functions

The following functions are available globally.

  • Short syntax for get object by tag Using:

    let object: YourType = by(tag: YourTag.self, on: *container)
    

    also can using in injection or init:

    .injection{ $0 = by(tag: YourTag.self, on: $1) }
    

    Declaration

    Swift

    public func by<Tag, T>(tag: Tag.Type, on obj: DIByTag<Tag, T>) -> T

    Parameters

    tag

    a tag

    obj

    resolving object

    Return Value

    resolved object

  • Short syntax for get object by two tags Using:

    let object: YourType = by(tags: YourTag.self, YourTag2.self, on: *container)
    

    also can using in injection or init:

    .injection{ $0 = by(tags: YourTag.self, YourTag2.self, on: $1) }
    

    Declaration

    Swift

    public func by<Tag1, Tag2, T>(tags: Tag1.Type, _ t: Tag2.Type, on obj: DIByTag<Tag1, DIByTag<Tag2, T>>) -> T

    Parameters

    tag

    a tag

    obj

    resolving object

    Return Value

    resolved object

  • Short syntax for get object by three tags Using:

    let object: YourType = by(tags: YourTag.self, YourTag2.self, YourTag3.self, on: *container)
    

    also can using in injection or init:

    .injection{ $0 = by(tags: YourTag.self, YourTag2.self, YourTag3.self, on: $1) }
    

    Declaration

    Swift

    public func by<Tag1, Tag2, Tag3, T>(tags: Tag1.Type, _ t2: Tag2.Type, _ t3: Tag3.Type, on obj: DIByTag<Tag1, DIByTag<Tag2, DIByTag<Tag3, T>>>) -> T

    Parameters

    tag

    a tag

    obj

    resolving object

    Return Value

    resolved object

  • Short syntax for get many objects Using:

    let objects: [YourType] = many(*container)
    

    also can using in injection or init:

    .injection{ $0 = many($1) }
    

    Declaration

    Swift

    public func many<T>(_ obj: DIMany<T>) -> [T]

    Parameters

    obj

    resolving objects

    Return Value

    resolved objects

  • Short syntax for get many objects in bundle Using:

    let objects: [YourType] = manyInBundle(*container)
    

    also can using in injection or init:

    .injection{ $0 = manyInBundle($1) }
    

    Declaration

    Swift

    public func manyInBundle<T>(_ obj: DIManyInBundle<T>) -> [T]

    Parameters

    obj

    resolving objects

    Return Value

    resolved objects

  • Short syntax for resolve. Using:

    let yourObj: YourClass = *container
    

    Declaration

    Swift

    public prefix func *<T>(container: DIContainer) -> T

    Parameters

    container

    A container.

    Return Value

    Created object.