class

Anyway to find out the class that's associated to this variable?

I want to find out the type of the data that i am sending through a send function through gamekit. Basically i am storing that data in CFPropertyListRef. dataReceived is of type NSMutatableData. - (void) receiveData:(NSMutableData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context { // Read the ...

Validating C# base class constructor parameter

After running Code Analysis in VS2010 beta (FxCop for previous versions) I'm getting the following warning: In externally visible method 'Identity.Identity(WindowsIdentity)', validate parameter 'windowsIdentity' before using it. The constructor is: public Identity(WindowsIdentity windowsIdentity) : base(windowsIdent...

Java classes inheritance

Here, it says that: This gives MountainBike all the same fields and methods as Bicycle, yet allows its code to focus exclusively on the features that make it unique. This makes code for your subclasses easy to read. However, you must take care to properly document the state and behavior that each superclass defines, since that code ...

.NET - how to make a class such that only one other specific class can instantiate it?

I'd like to have the following setup: class Descriptor { public string Name { get; private set; } public IList<Parameter> Parameters { get; private set; } // Set to ReadOnlyCollection private Descrtiptor() { } public Descriptor GetByName(string Name) { // Magic here, caching, loading, parsing, etc. } } class Parameter ...

Is there a call_user_func() equivalent to create a new class instance?

How can I create a class with a given array of arguments to be sent to the constructor? Something along the lines of: class a { var $args = false; function a() {$this->args = func_get_args();} } $a = call_user_func_array('new a',array(1,2,3)); print_r($a->args); Ideally this needs to work, without modification to the class, i...

Javascript change class of an element

I have ul list and I need to change the class of one of <li> tags with javascript: <ul> <li>...</li> <li class="something"> <- need to change this class to "myclass" (javascript goes here)</li> <li>..</li> </ul> Thank you. ...

Defining a class

Just a quick question, im defining a class were only a set of integers is used. I cannot use the following datatypes in defining my class: set, frozenset and dictionaries. i need help defining: remove(self,i): Integer i is removed from the set. An exception is raised if i is not in self. discard(self, i): integer i is removed from th...

Newb C++ Class Problem

I am trying to get a grasp on pointers and their awesomeness as well as a better C++ understanding. I don't know why this wont compile. Please tell me what is wrong? I'm trying to initialize the pointer when an instance of the class is created. If I try with a normal int it works fine but when I tried to set it up with a pointer i get th...

How to getElementByClass instead of GetElementById with Javscript?

I'm trying to toggle the visibility of certain DIV elements on a website depending on the class of each DIV. I'm using a basic Javascript snippet to toggle them. The problem is that the script only uses getElementById, as getElementByClass is not supported in Javascript. And unfortunately I do have to use class and not id to name the DIV...

as3 - Access class attributes dynamically

public class SndFx { [Embed(source="Sounds/01.mp3")] public static const s01:Class; public static const s01s:Sound = new s01() as Sound; [Embed(source="Sounds/02.mp3")] public static const s02:Class; public static const s02s:Sound = new s02() as Sound; [etc...] } Can I access these attributes dynamically? I've got a number of ...

Access IBOutlet from other class (ObjC)

Hi, I've googled around and found some answers but I didn't get any of them to work. I have one NSObject with the class "A" and a second class "B" without an NSObject. In class "A" are my IBOutlets defined and I can't seem to figure out how to access those outlets from class "B"... I've found answered questions like http://forums.macru...

Delphi: constant class instance

If I define a record, I can define an instance of that record as a constant record e.g. Tunit = record _name: string; _scale: real; end; const metre: Tunit = (_name: 'metre'; _scale: 1.0; ) I need to do something similar where Tunit is a Class and metre is an instance of the class, but is a (particular) instance whose asso...

PHP Mixing server code with HTML output

I'm coding up a small script that'll take form data and do something with it. If it fails, it shows the error and the form again. If it succeeds, it'll show a success message. The backend code is using classes that'll throw exceptions if there's an error with the form data. The calls to the classes will be wrapped in a try{} catch{}. W...

Using functions from within the same class

This is probably a really simple question however Google isn't my friend today. I have something like this but it says call to undefined function <?php class myClass{ function doSomething($str){ //Something is done here } function doAnother($str){ return doSomething($str); } } ?> ...

Accessing a function in a class from other classes

What I want to do is access the query function in my database class form anther class. Evey time a query is done I track the time it takes and add the the query count, I want to do that for all query's. The layout I have now is: Global ----------------------------- | | database class ...

is there a __construct() equivalent for extended classes

I have a parent class: Abstract Class Base { function __construct($registry) { // stuff } } I then have at least 2 classes that extend that class class Cms extends Base { // a few functions here } and this one class Index extends Base { // a few functions here } For the CMS class, the user will need to be l...

Dynamically import class by name for static access

I am generating class names dynamically and then want to import that class by its name to access a static method. This is the class to import in "the_module.py": class ToImport(object): @classmethod def initialize(cls, parameter): print parameter According to a Blog post this is as far as I came: theModule = __impor...

instantiating a new class in a loop or not in a loop?

require_once('Class.php'); $myArray = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // etc which is correct? foreach($myArray as $key => $val) { $class = new Class(); $result = $class->someMethod($val); } or $class = new Class(); foreach($myArray as $key => $val) { $result = $class->someMethod($val); } Edited to be more...

Java class with only static fields and methods - bad or good practice?

I have a Java class that only consists of static member variables and static methods. It is basically serving as a utility class. Is this a bad practice to have a class that only consists of static member variables and static methods? Thanks Steve ...

C# Newbie Question from tutorial book: "Head Start C# Greyhound Lab"

Hello, I'm an extreme newbie at C#, but I've been slowly moving through the Head Start C# tutorial book (and finding it extremely enjoyable so far). However, I've hit a wall on the first "lab" assignment: They give code for controlling a PictureBox, and I can get that code to work on the main Form, but I can't get it to work from withi...