subclassing

Calling super.init() in initializer of NSObject subclass in Swift

喜你入骨 提交于 2020-01-02 00:48:29
问题 I'm building an iOS app in Swift and drawing on the Lister sample project Apple provides. Lister uses two model objects: List and ListItem. I found that both of them do not call super.init() in their initializers even though they subclass NSObject. However, in the Objective-C version of Lister, both model objects (AAPLList and AAPLListItem) do call [super init] . The Swift Programming Language clearly states that “designated initializers must call a designated initializer from their immediate

C#: Marshalling a “pointer to an int array” from a SendMessage() lParam

一笑奈何 提交于 2019-12-31 04:17:53
问题 I'm trying to subclass an unmanaged statusbar window from my managed COM server using a class inherited from NativeWindow, and am running into a wall trying to make sense of how to properly marshal the contents of an lParam. http://msdn.microsoft.com/en-us/library/bb760757%28VS.85%29.aspx says that the contents of this lParam is of type (LPARAM)(LPINT) aWidths , and that the contents of this variable is actually a "pointer to an integer array." I can't figure out a way to marshal this

Why there are no OutOfMemoryError subclasses?

≡放荡痞女 提交于 2019-12-30 09:08:31
问题 As we all know, there are multiple reasons of OutOfMEmoryError (see first answer). Why there is only one exception covering all these cases instead of multiple fine-grained ones inheriting from OutOfMEmoryError ? 回答1: I'd expect because you really can't do anything else when that happens: it almost doesn't matter WHY you ran out, since you're screwed regardless. Perhaps the additional info would be nice, but... I know tomcat tries to do this "Out Of Memory Parachute" thing, where they hold

Why doesn't Apple allow subclassing of UINavigationController? And what are my alternatives to subclassing?

╄→гoц情女王★ 提交于 2019-12-29 04:18:08
问题 I'm currently building a tabbed iPhone application where each tab's view controller is an instance of UINavigationController , and where every subcontroller of every one of the UINavigationController instances is an instance of UITableViewController . Ideally, I'd like to subclass UINavigationController so that the controller for each tab is a subclass of UINavigationController that (in addition to having all the standard UINavigationController functionality, obviously) serves as the

Why doesn't __rmod__ work properly for strings? [duplicate]

大城市里の小女人 提交于 2019-12-25 18:12:33
问题 This question already has an answer here : Is it possible to overwrite str's % behaviour using __rmod__? (1 answer) Closed 2 years ago . >>> class MyInt(int): ... def __rmod__(self, other): ... return 42 ... >>> class MyStr(str): ... def __rmod__(self, other): ... return 'wat' ... >>> 0 % MyInt() 42 >>> '%r' % MyStr() "''" Why is the int subclass able to control this BinOp from the reflected side, but str can not? This seems to contradict the documented datamodel. I was hoping to use the

Is there any way to know if a window procedure was subclassed?

我是研究僧i 提交于 2019-12-25 17:10:07
问题 I want to check if winproc of a window form was subclassed. Any winapi or spy++ trick to do this? 回答1: you can use next code for determinate is window subclassed by another module (different from module which register window class ) BOOL IsSubclassed(HWND hwnd) { LPARAM pfn = (IsWindowUnicode(hwnd) ? GetWindowLongPtrW : GetWindowLongPtrA) (hwnd, GWLP_WNDPROC); HMODULE hmod; //if (RtlPcToFileHeader(pfn, &hmod)) if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS| GET_MODULE_HANDLE_EX

Subclass a button within a custom class using SetWindowSubclass [duplicate]

帅比萌擦擦* 提交于 2019-12-25 04:12:36
问题 This question already has answers here : Why callback functions needs to be static when declared in class (6 answers) Closed 3 years ago . I am attempting to write a class to handle the creation of a button and it's messages internally. I wish to keep all of the code contained within the class itself. This may be simple or impossible as I am relatively new to Winapi and C++, having used vb.net much more extensively. I was unable to find an example that accomplished this seeming simple

Convert instance of a parent class into its subclass

╄→гoц情女王★ 提交于 2019-12-24 11:12:10
问题 I've subclassed UIImage to create UIImageExtra. I have a method within UIImageExtra called adjustForResolution that adjusts the size of the UIImage. However I want it to return a UIImageExtra. I understand that I need to convert it but not exactly sure how. Basically, if I resize a UIImageExtra it becomes a UIImage. Here is my UIImageExtra class: #import "UIImageExtra.h" #import <objc/runtime.h> #import "UIApplication+AppDimensions.h" #define kOriginData @"originData" @implementation

The easiest way to subclassing C# System.Type

吃可爱长大的小学妹 提交于 2019-12-24 05:39:07
问题 I need to make fixed point number class inherit from System.Type. class FixedPoint : Type { public bool Signed { get; set; } public int Width { get; set; } public int IntegerWidth { get; set; } public FixedPoint(Boolean signed = false, int width = 16, int integerWidth = 8) { Signed = signed; Width = width; IntegerWidth = integerWidth; } } When I tried to compile this code, I got error messages saying that I need to implement methods as Type is abstract class. userdef.cs(3,7): error CS0534:

Regarding Java subclasses inheriting methods that return “this”

僤鯓⒐⒋嵵緔 提交于 2019-12-24 03:37:10
问题 Have a class Car with a public method public Car myself() { return this; } Have a subclass Ferrari , and a variable foo that contains a Ferrari object. Finally, Ferrari bar = foo.myself(); This will warn you, because the method myself() returns a Car object, rather than the expected Ferrari . Note: I know that the example is stupid because you'd just do bar = foo . It's just an example. Solutions: Override the myself() method in Ferrari . Cast the Car object to a Ferrari object when assigning