Questions tagged [class-extensions]

102 questions
1
vote
1 answer

Forward declaration of objective-c class extension method

The following code produces error No visible @interface for 'Bar' declares the selector 'barMethod' on the second line of implementation of -[Foo fooMethod]: // FooBar.m #import "FooBar.h" ////////////////////////////////// @implementation…
Alexander Vasenin
  • 11,437
  • 4
  • 42
  • 70
1
vote
2 answers

PHP check if method called from extened class

I have code two classes class old{ function query(){ #do some actions ... } function advancedQuery(){ #some actions and then $this->query(); } } and class awesome extends old{ function query(){ …
1
vote
2 answers

What is the difference between declaring a member in the extended interface versus in the implementation?

I am seeing two very different behaviors for something that I thought were the exact same. Defining my private member in the class extension like this: @interface ClassA () @property ClassB* b; @end @implementation…
1
vote
0 answers

Extend HashMap to implement custom remove()

I tried to extend the HashMap class to implement a custom remove() method, like this: @SuppressWarnings("serial") private final class EntryHashMap extends HashMap { @Override public E remove(Object key) { …
ilomambo
  • 8,290
  • 12
  • 57
  • 106
1
vote
0 answers

doxygen objective c uml associations for non-public associations with class extensions

Doxygen version 1.8.3.1-20130209 Love using Doxygen to generate class diagrams, etc. Just ran it against some Objective C that has some class extensions with @property declarations using other classes. It does not seem to be picking these up as…
ort11
  • 3,359
  • 4
  • 36
  • 69
1
vote
2 answers

Add ivar and property to class using class extension

I'm trying to add an instance variable and a property to an existing class. I want to do this to extend the base class of an open source library, without modifying the source code (for easier code management). The documentation says Unlike regular…
1
vote
2 answers

Questions about Class Extensions and inheritance in objective-c

I do not have anything in particular to achieve, but rather I am trying to learn more about class extension. This is the explanation of class extension directly from apple Categories and extensions: @interface MyClass : NSObject @property (retain,…
Leonardo
  • 9,607
  • 17
  • 49
  • 89
1
vote
1 answer

Why Does This Category Work? Category vs. Class Extension

This is what I have in my implementation file for one of my classes... Code Setup #1 @interface MyViewController (PrivateMethods) - (NSString *)myPrivateMethod; @end @implementation MyViewController - (void)viewDidLoad { NSString *myString =…
MikeS
  • 3,891
  • 6
  • 35
  • 51
1
vote
2 answers

C# style class extension in objective-c

I'm just learning objective-c after a fair amount of experience with C#. One of the things I sorely miss is the ability to write extension methods in a separate project that I could reference in all of my projects. Here's some naive c#: public…
Tin Can
  • 2,540
  • 2
  • 29
  • 39
0
votes
0 answers

Enum fun... Why these 2 errors and how to solve them?

Why these 2 errors and how to solve them? Code: public static class EnumExtension { public static T EnumFlagsAll(this T myEnum) where T : Enum { #pragma warning disable CS8600 // Converting null literal or possible null…
Eric Ouellet
  • 10,996
  • 11
  • 84
  • 119
0
votes
1 answer

C# How/Possible to add new property to existing class dynamically or with class extension?

So, I have an object, and it would be very beneficial if I could include a reference to another object within this object upon its creation. In this specific circumstance the class that is being used is: Windows.UI.Xaml.Shapes.Rectangle So the way I…
Bishiba
  • 103
  • 8
0
votes
0 answers

How to add a required protocol property to an extension?

I'm trying to make a class conform to a protocol by extending that class. In my case I'd like to conform SKNode to UIAccessibilityIdentification. UIAccessibilityIdentification has only one requirement, that is the property accessibilityIdentifier,…
0
votes
1 answer

Applying superclass array extensions to arrays of subclass instances

Is there a way to use an array extension that has been applied to a superclass on arrays of subclass instances? I am attempting to do so in the following way: Extension on superclass: extension Array where Element == Superclass { func…
kamisama42
  • 595
  • 4
  • 18
0
votes
1 answer

c# StringBuilder with Linq-ish capabilities IfElse is this possible?

I'm writing down an AST (abstract syntax tree) not in tree form but with the intent of correctly formatting my code.. similar to Clang for a custom language and I'm using a StringBuilder for the effect... Right now I have to do things like: …
xDGameStudios
  • 321
  • 1
  • 13
0
votes
1 answer

How to get the View for a class, that extends a class that extends Fragment/activity etc

I am having a problem were I have: class x that extends y and class y that extends Fragment I wan to be able to do things in x that for eg get a textview with ID and change the text. To do this, I must get the view but I get problems. I have tried…