Skip to content
This repository was archived by the owner on Oct 13, 2018. It is now read-only.
This repository was archived by the owner on Oct 13, 2018. It is now read-only.

Missing Product Recipe #27

@steve228uk

Description

@steve228uk

Howdy!

I've been working on some recipes for the Product and Descriptive Alert templates. Once completed, did you want me to submit a PR?

I'm also not sure of the best approach in handling actions. Is there a way for a recipe to intercept these or is it one global handler for the application? Currently I'm using the following:

func actionIDHandler(id: String) {
   switch id {
   case "showDescription":
       DescriptionRecipe.show(selectedMovie)
       break
   default:
       break
   }
}

My approach in generating the XML is slightly different to yours too and I'd appreciate your opinion on whether this is a good idea or not. I have an XML file called product.xml that has placeholders such as {{TITLE}} and {{DESCRIPTION}}. These are then replaced to generate the final template with the following:

public var template: String {
    var xml = ""
    if let url = NSBundle.mainBundle().URLForResource("product", withExtension: "xml") {
        xml = try! String(contentsOfURL: url)
        xml = xml.stringByReplacingOccurrencesOfString("{{DIRECTOR}}", withString: director)
        xml = xml.stringByReplacingOccurrencesOfString("{{TITLE}}", withString: title)
        xml = xml.stringByReplacingOccurrencesOfString("{{ACTORS}}", withString: actorString)
        xml = xml.stringByReplacingOccurrencesOfString("{{DESCRIPTION}}", withString: description)
        xml = xml.stringByReplacingOccurrencesOfString("{{IMAGE}}", withString: image)
        xml = xml.stringByReplacingOccurrencesOfString("{{YEAR}}", withString: year)
    }
    return xml
}

simulator screen shot 14 mar 2016 00 51 09
simulator screen shot 14 mar 2016 00 51 03

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions