title: Swift: Enums that use closures?
body: <p>I’m creating an application where an unlimited amount of rules could be applied to an unlimited amount of nodes.  </p>
  
  <p>I'm planning on using core data as the datastore and creating a simple one to many relationship between node and rule.</p>
  
  <p>In objective-c I would probably create classes for each of the rules and have them conform to a protocol.</p>
  
  <pre><code>NSArray *ruleClassNames = @[@"SimpleRuleA",@"SimpleRuleB",@"BigFatComplicatedRule"];
  
  int ruleType = [someNode.rules firstObject];
  Class class = NSClassFromString(ruleClassNames[ruleType]);
  
  [(ruleClassProtocol*)class performSelector:@selector(runRuleOnNode:) withObject:someNode];
  </code></pre>
  
  <p>What would be the most elegant way of doing this in swift?</p>