Questions tagged [class-extensions]
102 questions
2
votes
1 answer
Adding Instance Variable to NSData
So, I understand that Categories in Objective-C can be used to add methods to classes without the need for subclassing. I also understand that these Categories cannot be used to add instance variables to classes.
I did a little bit of reading about…

Michael D.
- 399
- 4
- 16
2
votes
5 answers
Creating an extension to a class?
In some languages like C# and Objective C, you can create class extensions. That means you can add additional methods to an existing class without having to extend that class. Is this possible in Java?

aryaxt
- 76,198
- 92
- 293
- 442
2
votes
2 answers
How a class extension works as a means of implementing private methods
I believe a popular way to declare "private methods" in Objective-C is to create its class extension and declare methods that you would like to make as private.
I would like to know more in detail on how an class extension makes the methods work as…

Ryan Rho
- 515
- 5
- 18
2
votes
0 answers
Visibility of methods in class extensions in Xcodes code completion
I saw a similar question addressing differences of the code completion between Xcode 3.2 and Xcode 4. My question addresses a specific behaviour of Xcode (3.2).
When I declare "private" methods in a class extension, these methods are visible in the…

Felix Lieb
- 414
- 3
- 14
2
votes
1 answer
Is using both Inheritance and Composition a good practice in React Class Components?
I will best explain what I am trying to say with an example:
I want to create a hoverable component which can be reused.
If I use only extension the code will look like this:
Inheritance:
class HoverableComponent extends React.Component {
…

but-why
- 533
- 3
- 10
2
votes
1 answer
Is it possible to extend a class from __init__.py
I have written a small python package which extends a pandas dataframe with a few additional methods.
At the moment, I have this code in my package:
def init():
@pd.api.extensions.register_dataframe_accessor("test")
class _:
def…

Christian Brinch
- 99
- 7
2
votes
2 answers
Extensions with stored properties
I'm still learning Swift, and I'm trying to create an extension to add a placeholder to UITextView.
My idea for it is to create 2 UITextViews, one with a text as a placeholder, and when the user starts editing the text, it's actually hidden and…

Ennabah
- 2,303
- 2
- 20
- 39
2
votes
2 answers
Linker cannot find a class that should be there
I have a project that uses the Core Telephony framework. Recently my code stopped working on a CTCarrier category, the linker complains that it can’t find the CTCarrier class:
Undefined symbols:
"_OBJC_CLASS_$_CTCarrier", referenced from:
…

zoul
- 102,279
- 44
- 260
- 354
2
votes
1 answer
How to extend the JComboBox class?
I'm writing a Java GUI. I have a few preset JComboBoxes and to be able to distinct them from each other, I want to extend the class and add an enum variable that can help me distinct them from each other.
Here's an MCVE of two standard…

Zeliax
- 4,987
- 10
- 51
- 79
2
votes
1 answer
Extending Clearance gem controllers
I am trying to extend clearances controllers to pass through some other form elements
I have currently done the following but it doesn't appear to be working and is returning ActiveModel::ForbiddenAttributesError
class UsersController <…

Boss Nass
- 3,384
- 9
- 48
- 90
2
votes
2 answers
How to add conformance to _Incrementable in NSDate
I am trying to add conformance to ForwardIndexType in NSDates so I can make a Range, in order to do it I must implement public func successor() -> Self from _Incrementable.
My implementation is really simple and aims to state the date that…

fpg1503
- 7,492
- 6
- 29
- 49
2
votes
3 answers
Expose Objective C Class Extension Property in Swift
Say I have the following in an Objective C implementation file (MyVC.m):
@interface MyVC ()
@property (nonatomic, weak) IBOutlet UILabel *titlelabel;
@end
How can I expose this private property to Swift (test) code? The following causes compiler…

pr1001
- 21,727
- 17
- 79
- 125
2
votes
5 answers
I need help mixing C++ code and Objective-C code
I am writing a device driver for a Blackmagic Design AV device in XCode, and I'm having trouble including BMD's SyncController class from their abbreviated sample code (below) into my purely Objective-C project.
Their DecklinkAPI.h file is rich in…

zzyzy
- 973
- 6
- 21
2
votes
2 answers
Accessing a property defined in the class extension from a category, in Objective-C: is it possible?
One of my classes MyClass is very big and I want to split it into several categories MyClass(A), MyClass(B), ... . My problem is that some of the methods of MyClass+A make use of a @property defined in the class extension MyClass().
Can I access it…

Colas
- 3,473
- 4
- 29
- 68
2
votes
1 answer
Backbone JS add extended model to a collection of its inherited model type
I've just started digging into backboneJS, and have built started building a small text app in codepen (http://codepen.io/azaslavsky/pen/fJghE). Everything is going well, except I have one problem: once the user hits the submit button, I'd like for…

AlexZ
- 11,515
- 3
- 28
- 42