Skip to content

rahulnadella/ObjectFactory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ObjectFactory

Overview

This project is an example implementation of creating objects in Swift using a bridging header file. This project should be run from the command line.

#####Version

Version 1.0 - Design and Implementation of the ObjectFactory

Usage

The example shown below can be found in main.swift.

    let namespace = "ObjectFactory"

    typealias PersonFactory = ObjectFactory<Person>

    func createPersonWithClassName(
        className: String!,
        personName: String? = nil)
    {
        let qualifiedName = "\(namespace).\(className)"
        if personName != nil
        {
            if let person = PersonFactory.createInstance(
                className: qualifiedName,
                initializer: "initWithName",
                argument: personName!)
            {
                println("\(className) name = \(person.name)");
            }
        }
        else
        {
            if let person = PersonFactory.createInstance(className: qualifiedName)
            {
                println("Created a \(className)");
            }
        }
    }
    
    createPersonWithClassName("Stranger")
    createPersonWithClassName("Friend", personName: "Steve")

License

MIT License --> A short, permissive software license. Basically, you can do whatever you want as long as you include the original copyright and license notice in any copy of the software/source. There are many variations of this license in use.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published