subclass

UIViewController subclass can't assign instance variable

萝らか妹 提交于 2019-11-28 01:33:37
This is utterly baffling to me, making me think I've missed something essential. But I'm trying to create a view controller container to manage two panes (similar to a SplitViewController but with some crucial differences). I've barely begun constructing the class, so I've only got 3 iVars right now: @implementation SplitViewController{ BOOL _showLeftPane; UIViewController *_leftController; UIViewController *_rightController; } No matter what I do, I cannot assign a view controller to the _leftController iVar. Mostly, the _rightController iVar can assign. It get's weirder. If I switch the

How to add properties to NSMutableArray via category extension?

给你一囗甜甜゛ 提交于 2019-11-28 01:21:29
I know that I can "subclass" an NSMutableArray using "category extensions," i.e. @interface NSMutableArray (MyExtension) , to add new functions to the class. However, is there a way using category extensions to also add new properties to the extension? Note that @interface NSMutableArray (MyStuff) is a category and not a class extension . They are similar in this context, but actually do have quite a few different details. You can't add storage to an existing class through either mechanism. You can use Associative References to associate data with an instance, though. As you said, categories

No Matching Function Call to Base class

纵饮孤独 提交于 2019-11-28 01:20:24
问题 Here I am trying to make a subclass of the base class, Airplane. In my main code I haven't tried to use either constructor yet as I am just trying to make sure I can make the subclass Fighter to properly work. The exact error its giving me is no matching function for call to 'Airplane:Airplane()' And says it pertains to this line of code in the Fighter.cpp Fighter::Fighter(int engi, int seat, string description) Fighter.cpp #include "Fighter.h" Fighter::Fighter(int engin, int seat, string

Delphi subclass visual component and use it

烈酒焚心 提交于 2019-11-28 00:18:19
I would like to subclass TToolBar with another class called MyTToolBar so that I can override a method. I'm new to Delphi, but after two hours of trying various methods, I can't get MyTToolBar to be used instead of TToolBar. I can't be the first person who's wanted to override a method on a visual component class. I come more from an Xcode background where subclassing a visual component is easy. You create a subclass (e.g., MySubclass) of a parent class (e.g., MySuperClass) and then just simply assign the subclass in the Interface Builder view of Xcode. The subclass is automatically recognized

Java memory usage in inheritance

五迷三道 提交于 2019-11-28 00:05:53
问题 What does the memory usage look like in Java when extending a base class. Do the child class contain an instance of the base class (with it's own overhead and all) or does it only have it's own overhead of 16 Bytes? class Foo { int x; } class Bar extends Foo { int y; } So, more specifically, what is the memory usage of an instance of Bar? Is it Foo (including overhead) + Bar(including overhead) or just Foo (excluding overhead + Bar(including overhead) 回答1: There is no double overhead. Java

In C# 4.0, is it possible to derive a class from a generic type parameter?

大兔子大兔子 提交于 2019-11-27 23:29:05
I've been trying this, but I can't seem to figure this out. I want to do this... public abstract class SingletonType<TSingleton, TBaseClass> : TBaseClass where TSingleton : TBaseClass, new() where TBaseClass : class { static TSingleton _singleton; public static TSingleton Singleton => _singleton ?? (_singleton = new TSingleton()); } The plan was to use it like this which would sort of 'wrap' the singleton pattern around a base class... public class SingletonFoo : SingletonType<SingletonFoo, Foo> { } However, I keep getting this Cannot derive from 'TBaseClass' because it is a type parameter Um.

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

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 23:22:52
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 a subclass's initWithFrame result in an infinite loop? If this is required, then does this mean I can't create a new init function within a subclass such as initWithPoint and have that call super's init or initWithFrame simply because the super class doesn't have

Extending MediaController for android

拈花ヽ惹草 提交于 2019-11-27 23:17:59
I am using a VideoView and the MediaController for an app I am working on. I simply wanted to have the MediaController appear on top of my VideoView but apparently you can't do that very easily. I attempted to use the setAnchorView method to my VideoView id, but that didn't work. No matter what I do, the MediaController is always at the bottom of my screen. With that said, I did some research and it looks as if I go about extending MediaController , I can change position and other properties. I have created a new class: package com.dop.mobilevforum; import android.content.Context; import

Subclassing numpy ndarray problem

萝らか妹 提交于 2019-11-27 23:06:55
I would like to subclass numpy ndarray. However, I cannot change the array. Why self = ... does not change the array? Thanks. import numpy as np class Data(np.ndarray): def __new__(cls, inputarr): obj = np.asarray(inputarr).view(cls) return obj def remove_some(self, t): test_cols, test_vals = zip(*t) test_cols = self[list(test_cols)] test_vals = np.array(test_vals, test_cols.dtype) self = self[test_cols != test_vals] # Is this part correct? print len(self) # correct result z = np.array([(1,2,3), (4,5,6), (7,8,9)], dtype=[('a', int), ('b', int), ('c', int)]) d = Data(z) d.remove_some([('a',4)])

drawTextInRect on UITextField not called

北战南征 提交于 2019-11-27 23:06:42
I'm trying to implement the answer to this SO question . The problem is: -[drawTextInRect] is apparently not called, and setting the shadow in -[drawRect] doesn't make the UITextField's text shadowed. Another weird thing is that even if my subclass implementations of -[drawTextInRect] and -[drawRect] are completely empty (not even a call to super), the textfield's text is drawn. This is a bug in the UITextField API documentation. The documentation indicates that overriding drawTextInRect: can be used to customize behaviour. This is not the case. In fact, drawTextInRect: will never be called on