instance-variables

How can I assign to an instance variable in C++ when a local variable has same name?

I have a class defined like this: class MyClass { int x; public: MyClass(int x); }; MyClass::MyClass(int x) { //Assign x here } However, I can't initialize x in the constructor because it has the same name as an instance variable. Is there any way around this(other than changing the name of the argument)? ...

How to access the instance variable of the view from its subview in iphone

I am new to iphone development.I want to to access the instance variable declared in uiview from its uiview subview.please help me out .Thanks. ...

Calling function in other Class not working

Hey everyone, not sure what is going on here :( Basically I have a function that is needs to tell 2 other classes to do something. It works for one of the classes: BigPlayButton, but not Background for some reason. TabMenu.as Class function Note: The function below WILL call the hitPlayCircle function in my BigPlayButton class, but I ...

How to include/require/load a file in ruby with instance variables

I would like to put a large variable definition in a separate file for the sake of getting it out of the way. I must be doing something wrong though, because my puts call isn't putting anything out. my_class.rb: class foobar def initialize require 'datafile.rb' puts @fat_data end end datafile.rb: @fat_data = [1,2,3,4,5,6...

How to access ivar from class method of other implementation file

The title says it all, how do I access properties (title, state,...) of instance variables from within a class method of an other implementation file? I tried @synthesize but I couldn't get it to work. To be more precise; I need to access IBOutlets of an NSWindowController class. ...

Best practice for copying private instance vars with NSCopying

I might be missing something obvious here, but I'm implementing NSCopying on one of my objects. That object has private instance variables that are not exposed via getters, as they shouldn't be used outside the object. In my implementation of copyWithZone:, I need alloc/init the new instance, but also set up its state to match the curre...

C# Copying instance variable to local variable in functions of same class

I have been looking through some code on an open source project recently and found many occurrences of this kind of code: class SomeClass { private int SomeNumber = 42; public ReturnValue UseSomeNumber(...) { int someNumberCopy = this.SomeNumber; if (someNumberCopy > ...) { // ... do some...

Is it possible to get all member variables in flash(AS3)?

Hi, I am trying grab all the member variables in AS3, and then foreach one i would like to process it in various ways. I would need the name and then if it is a collection of some type I would like to loop through that collection as well. I am attempting to essentially serialize in a somewhat custom fashion. Thanks! ...

What's the Difference Between These Two Ruby Class Initialization Definitions?

I'm working through a book on Ruby, and the author used a slightly different form for writing a class initialization definition than he has in previous sections of the book. It looks like this: class Ticket attr_accessor :venue, :date def initialize(venue, date) self.venue = venue self.date = date end end In previous sec...

Ruby class instance variables and inheritance

I have a Ruby class called LibraryItem. I want to associate with every instance of this class an array of attributes. This array is long and looks something like ['title', 'authors', 'location', ...] Note that these attributes are not really supposed to be methods, just a list of attributes that a LibraryItem has. Next, I want to mak...

Is it true that in most Object Oriented Programming Languages, an "i" in an instance method always refers first to local, and then to global, but never to the instance variable or class variable?

In the following code: <script type="text/javascript"> var i = 10; function Circle(radius) { this.r = radius; this.i = radius; } Circle.i = 123; Circle.prototype.area = function() { alert(i); } var c = new Circle(1); var a = c.area(); </script>...

Is there a way to inspect all controller variables at once in Rails?

I am exploring an big controller method, with about 10 or so instance variables. Some of them are set in before_filter methods, and some others inside the method itself. I want to inspect them with puts, but dont want to write all of them out example: puts "var1: #{@var1.inspect}....var15: #{@var15.inspect}" Is there a generic method ...

ruby get instance variables in hash, not an array? how to do it?

ruby get instance variables in hash, not an array? how to do it? ...

Using RJS to replace innerHTML with a real live instance variable.

I can't for the life of me get RJS to replace an element's innerHTML with an instance variable's attribute, i.e. something like @thing.name I'll show all the code (simplified from the actual project, but still complete), and I hope the solution will be forehead-slap obvious to someone... In RoR, I've made a simple page displaying a ran...

Ruby on Rails- :symbols, @iVars and "strings" - oh my!

New to Rails and trying to get my head around when/why to use :symbols, @ivars , "strings" within the framework. I think I understand the differences between them conceptually only one :symbol instance per project one @ivar per instance multiple "strings" - as they are created whenever referenced (?) Feel free to correct me! The ma...

Why doesn't my UIViewController class keep track of an NSArray instance variable.

Hey, I am new to Objective-C 2.0 and Xcode, so forgive me if I am missing something elementary here. Anyways, I am trying to make my own UIViewController class called GameView to display a new view. To work the game I need to keep track of an NSArray that I want to load from a plist file. I have made a method 'loadGame' which I want to l...

In Ruby, how to write a method to display any object's instance variable names and its values

Given any object in Ruby (on Rails), how can I write a method so that it will display that object's instance variable names and its values, like this: @x: 1 @y: 2 @link_to_point: #<Point:0x10031b298 @y=20, @x=38> (Update: inspect will do except for large object it is difficult to break down the variables from the 200 lines of output, ...

Objective-C: Cannot Change Value of Instance Variable Inside a Function

Hello everyone, I cannot change the value of an instance variable inside a function. I have defined a class: // info.h #import <Foundation/Foundation.h> @interface NSMyObject : NSObject { NSInteger i; } -(void) setI:(NSInteger)v; @end #import "info.h" @implementation NSMyObject -(void) setI:(NSInteger)v ; { i=v; ...

Properties and Instance Variables in Objective-C 2.0

Do properties in Objective-C 2.0 require a corresponding instance variable to be declared? For example, I'm used to doing something like this: MyObject.h @interface MyObject : NSObject { NSString *name; } @property (nonatomic, retain) NSString *name; @end MyObject.h @implementation @synthesize name; @end However, what if I did thi...

tomcat - CATALINA_BASE and CATALINA_HOME variables

I have multiple instances of tomcat 6 running on the same server (Linux) and it works as expected. I am trying to find out what the standard practice is with regards to setting the CATALINA_HOME and CATALINA_BASE variables. In my tomcat installation, I have setup CATALINA_HOME to point to a "common" folder (say /tomcat6) and the CATALIN...