class-cluster

"out of scope" error when iterating an NSMutableArray

Why am I getting an "out of scope" error whenever I try to access the "url" variable in this loop? for(NSString *url in self.winnerImageURLs) { [mediaItemString appendFormat:@"{\"type\":\"image\",\"src\":\"%@\",\"href\":\"%@\"},", url, url]; } The class of very item in the "self.winnerImageURLs" NSMutableArray comes back a...

Class cluster initialization

My iPhone app has an abstract class WorkingView. It is a subclass of UIView. WorkingView will in turn have a bunch of concrete subclasses. Two of those will be SimplifyView and MultiplyView. I am trying to write the method that creates new instances of WorkingView. This method should have the mode passed in and return an instance of...

How to create a "class cluster" (factory class with instances of concrete subclasses) in Ruby?

I would like to create an abstract class which will create concrete instances depending on initialization parameter. Example: class SomethingGeneric def self.new(type, arg) class_name = "#{type.capitalize}Something" if obj.const_defined?(class_name) a_class = obj.const_get(class_name) else raise ArgumentErr...