subclass

How to add constraints on inherited properties in a grails domain sub-class

Here's what I'd like to do: class A { String string static constraints = { string(maxSize:100) } } class B extends A { static constraints = { string(url:true) } } So class A should have some constraints and B should have the same plus additional constraints on the same property. I couldn't get that to work though a...

In Moose, how can I make a class's constructor return an instance of a subclass?

Possible Duplicate: How to have Moose return a child class instance instead of its own class, for polymorphism Suppose I have two related classes MyClass::A and MyClass::B that are both subclasses of MyClass. I would like the constructor for MyClass to take a filename, read the file, and based on the contents of the file, deci...

Resizing a UIView subclass with dynamic sized subviews

I currently have a UIView subclass that acts as my header view for my UITableViewController. All of the subviews vary in size depending on data retrieved for a particular item. layoutSubViews is getting called for the UIView before I can determine the size of each label. This causes a problem because I set the size of the view within th...

How do I declare a variable that contains a subclass of a class which implements an interface?

I want to declare a variable which holds a class which implements a specific interface. Specifically, I'm trying to store a SocketChannel and a DatagramChannel in the same property so I can use them interchangeably. Both of these classes extend SelectableChannel and also implement ByteChannel, and I wish to call methods from both. I d...

UIControl subclass is unable to take a target?

I've subclasses UIControl and in it I am sending: [self sendActionsForControlEvents:UIControlEventValueChanged]; When I create an instance of the object, I add a target as follows: [starView addTarget:self action:@selector(starRatingChanged:) forControlEvents:UIControlEventValueChanged]; The view shows up fine, and without the targ...

Fluent NHibernate Hierarchical Data Question (One Table Per Hierarchy)

I am having some trouble depicting a DataBase Setup in NH. I have the following Classes: public class BaseData { public virtual long Id { get; set; } } public class ExtendedData : BaseData { public virtual string Name { get; set; } } The backing tables look like the following: BaseTable -------...

why does initializing subclasses require calling the super class's same init function?

I have heard that when you have a subclass, you are supposed to initialize the superclass with the same init function from within the subclass's init. What I mean is that the subclass's init should call [super init] and the subclass's initWithFrame should call [super initWithFrame]. Why is this? Why does calling the super's init from ...

Making a single create form using Single Table Inheritance in Rails

Hello, I'm using STI in Rails, and I've got a Vehicle object, that has many different types of subclasses, like Car, Truck, etc. It's for a simple app, so STI works fine in this case, but I'm having trouble creating a single form where any type of Vehicle record can be created. Using the following routing: resources :vehicles resource...

Custom UITableViewCell for Settings-like application?

I'd like to have a settings view in my app. I want to have things like UILabels, UISwitches etc. (Like in the Settings app.) How can I go about doing that? Can I just replace the detailView with the required view, or is there more to it then that? That may not work because I need to be able to set and get text values too. ...

Text disappears in subclass of NSTextFieldCell

I've spent many hours trying to figure this one out with no luck. Someone had a similar problem on the Apple mailing lists a while ago and no one answered. Basically, it comes down to this: I've subclassed NSTextFieldCell and overridden the drawWithFrame: method to create a custom bezel. Then I call drawInteriorWithFrame: at the end of t...