Questions tagged [class-extensions]
102 questions
0
votes
0 answers
Struggling to combine method chaining with class extensions
I'm trying to combine method chaining with class extensions and a method that is defined in a base class. However, I struggle to get it to work, as I am not very familiar with Generics yet.
Could someone maybe help me to get this to work? It would…

Alex
- 223
- 1
- 6
- 21
0
votes
1 answer
How to extend CHttpSession class in yii1
First I want to say that i am really new in programming yii1.I have to catch the event when session is destroyed or closed in yii1 and redirect to index when the event is triggered.
I've tried to extend CHttpSession class and extend the method…

Claudiu
- 47
- 8
0
votes
1 answer
Ruby class extension in Rails works when declared locally, returns `nil` when imported from `/lib/`
TLDR: A hash extension works flawlessly, returning the desired output, when included locally in my Mailer, but always returns nil when imported from a module in lib/, even though the class method is successfully loaded.
When I declare the extension…

Reverse Engineered
- 331
- 4
- 16
0
votes
1 answer
self vs "generic typet" T difference when ceating extension
I run into an interesting behaviour which I don't understand. Here is code that produces this behaviour:
import UIKit
protocol UIViewNibLoading {
static var nibName: String { get }
}
extension UIView : UIViewNibLoading {
static var…

Vojta
- 810
- 10
- 16
0
votes
1 answer
Could I extend NSString class in Static Library and use it in App with Swift?
I extend NSString in my custom static library CommonLib :
//NSString+ext.h
#import
@interface NSString (ext)
- (BOOL)isContainsEmoji;
@end
//NSString+ext.m
#import "NSString+ext.h"
@implementation NSString (ext)
-…

hopy
- 559
- 3
- 18
0
votes
1 answer
accessing properties of a class and printing them
I have a header file like this:
@class NSMutableDictionary, NSString;
@interface randomclassname : NSObject
{
unsigned long long _HTTPMethod;
NSString *_path;
unsigned long long _apiVersion;
NSMutableDictionary *_parameters;
…

Biplov
- 1,136
- 1
- 20
- 44
0
votes
1 answer
How to navigate to extension methods such as MapHttpRoute of HttpRouteCollectionExtension
In Visual Studio 2012 I'd like to navigate to the MapHttpRoute method from the HttpRouteCollection class.
So for example if I go to the definition of Routes of Routes.MapHttpRoute(), I see Routes is an instance of HttpRouteCollection class. However…

Angel Cloudwalker
- 2,015
- 5
- 32
- 54
0
votes
2 answers
iOS - Make swift extension selectively visible
In swift, how do I make an extension visible to only a few classes and not to all?
I have added an extension to UIImage in a file called UIImage+filters.swift. I will be using this extension only in 2 classes in my project PhotoImage and…

iOSer
- 235
- 2
- 14
0
votes
1 answer
SIGABR exception when try to assign a property in a Singleton
I've got a SIGABRT when I assign value to the property "myLocal" of the class CMRequestManager in a Singleton Init. What's wrong?
@interface CMRequestManager (private)
@property (nonatomic,strong) NSString* myLocal;
@end
…

christian mini
- 1,662
- 20
- 39
0
votes
1 answer
Where is the private interface for my Objective-C class?
The tutorial book I'm reading told me to create a GameViewController file class, which I did, resulting in the following files showing on the left-hand side of Xcode:
GameViewController.h
GameViewController.m
Then just after this part in the book…

C-Smith
- 249
- 1
- 3
- 8
0
votes
1 answer
ivars vs class extensions
Assume all of the following code is written in an implementation file .Could somebody explain the difference between :
#1
@interface ViewController ()
@property (nonatomic) NSDictionary *currentAlbumData;
@end
@implementation…

karan satia
- 307
- 4
- 16
0
votes
1 answer
Need clarification on using dot-notation on literals in Swift
So I am reading about Class Extensions in the Swift documentation. I understand the purpose and functionality of a class extensions. Then, Apple provides this example of how to extend an existing type:
extension Double {
var km: Double { return…

Walter M
- 4,993
- 5
- 22
- 29
0
votes
1 answer
Trying to override NSView's drawRect from extension class
I am designing an NSView class extension in Swift. Inside that extension class, I am trying to override drawRect using this
extension NSView {
override func drawRect(rect: NSRect) {
}
There is an error pointing to the override and saying…

Duck
- 34,902
- 47
- 248
- 470
0
votes
2 answers
Extend class response in PHP
I'm working in a project using mySQL and SQLite DB. My goal is to make the code able to work with both database types. I developed the code for mySQL, using the mysqli class, and now I want to modify it to make it also work with SQLite3…

Pepin
- 3
- 2
0
votes
1 answer
Can you enforce type conversion in a protocol without defining a property/method?
I don't want to have to define asString.
protocol ConvertibleToString {var asString: String {get}}
extension Int: ConvertibleToString {
var asString: String {return String(self)}
}
user652038