objects

How to share an object between two class methods

I created an object in the method viewDidLoad:. In another method that I create, I want to access this object. One way to do it is to declare the object in the h file. Another way to do it is to pass it as a parameter. Are there any other ways? ...

Keeping track of created model objects and destroying them after tests?

Background: Test drivers for rails that can test AJAX functionality (e.g. Selenium, EnvJS, akephalos etc) don't support transactional fixtures. I'm using Machinist and looking to do Capybara testing so I need some way to clear the test database after each test. Truncating every table in the test database is really slow (this is what the ...

When querying a collection using linq it always returns a null

I posted up part of some code the other day but in doing so caused more confusion. This is my code. if ( HttpContext.Current.Session != null ) { if ( HttpContext.Current.Session[ "CurrentLabourTransactions" ] != null ) { Collection<JCTransLabour> oJCTransLabours = null; ...

How to sort this NSMutableArray?

I made a class called Person. It looks like this Person ------- Name Points Then I created an NSMutableArray called team. It contains several of these person objects. I create several teams. Then I created another NSMutableArray called allTeams. It holds all the team arrays. I want to sort the allTeams array by the total number of p...

How to change this code so the NSMutableArray is sorted?

I made a custom class. This is the h file @interface Player : NSObject { NSString *name; NSNumber *points; } @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSNumber *points; -(id) initWithName:(NSString *)n andPoints:(int)p; @end This is the m file #import "Player.h" @implementation Player @sy...

Why does A work but not B?

I have a custom class written, which I instantiate from an event procedure similar to Private Sub EventHandler For intForCounter = 1 to intUserEntry Dim newObj As New MyClass newObj.Property newObj.Method() Next End Sub The class itself looks something like this Public Property Time As Date 'First atte...

Doctrine - Compare two objects

Hi! What would to know the best way to compare two objects using Doctrine! On the domain login I am considering, two objects are equal if they have the same properties values, except the id and the created_at and updated_at auto-generated fields through the Timestampable behavior. Thanks in advance for the help, Best regards! ...

[Java] Question on how to refer to two specific objects in a method

So basically, we create four lines. One is created by giving a point (x,y) and the slope, the second is created by giving two points (x1, y1) and (x2,y2), the third is created as an equation in slope intercept form y=mx+b, and the fourth is given as an equation x=a with the line being vertical. To do that, we create four constructors. T...

Java: If object of same parameters exists do not add new object

Here is my object constructor static class Edge { int source; // source node int destination; // destination node int weight; // weight of the edge int predecessor; // previous node public Edge() {}; public Edge(int s, int d, int w) { source = s; destination = d; weight = w; } } Now, here is the statement where...

How to create object graph from an XML-file?

I have an XML file. It could be something like: <person> <name> <firstname>Joni</firstname> <lastname>Smith</lastname> </name> <born year="1983" day="31" month="01">Finland</born> ... lots of elements ... </person> My goal is to create class Person. How can I do it "automatically"? I think I have used some maven castor...

I'm having a hard time understanding java objects and classes

Example 1 /** *Program Name: Cis36L0411.java *Discussion: Class -- Data Members ONLY * Method Members ONLY */ class Cis36L0411 { public static void main( String[] args ) { DataOnly data1 = new DataOnly(); System.out.println( "DataOnly\tLIMIT\t\t" + data1.LIMIT ); System.out.print...

Editing one object in an NSMutableArray also changes another object in the NSMutableArray

I had a navigation application that was working normally. In the table view, the last item is called "add item", and if the user pressed it, it would create a new object and pass it to another view where the user could enter the details for that object. When the user returned to the previous screen, the new object would show in the array...

How to make a copy of a custom object

I made a custom object that inherits from NSObject. Let's say I have an array of these objects. Then I want to make another object, that is a copy of one of the objects in the array. I do not want to simply point to an existing object in the array I want a copy. Is there an easy way to do this? ...

Commenting Objects within Dojo classes with JSDOC toolkit

Hey, I've searched and have found partial answers but none that seem to working - at least as I expect - in my situation. So I am trying to comment http://pastebin.com/eRF0VjmR and running into issues when I try to comment objects. The ones in question are "subscribers", "options", and "fn". As you can see for "fn" (line 756) I am u...

Using Jquery to dynamically create objects

I'm trying to dynamically create objects out of forms, but I want some reduntant elements to be ommitted, such as the submit. The only problem is that my function won't omit these fields. function form_to_json(formname) { var obj = new Object(); var identity = "#" + formname + " input"; // Create JSON strings ~~~~~~~~~...

How do I create a JavaScript Object with defined variables and functions?

Let's say I want to create an Object called 'Vertex'. Usually, in Java I would do this by: public class Vertex { // member variables public data; private id; // member methods public Vertex() { /* default constructor */ } public getID() { return id; } } Now, how would I do that in JavaScript? I want to preserve pri...

Difference in ways of deleting object array

Is there some difference in the following deletions of object array? The first way: MyClass **obj = new MyClass*[NUM]; for (int i=0; i<NUM; i++) obj[i] = new MyClass(val); obj[0]->method(); for (int i=0; i<NUM; i++) delete obj[i]; /// Deletion1 delete obj; /// Deletion1 The second way: MyClass **obj = ne...

VB .Net 2008 - List all objects currently in scope?

Hi Guys, Please can any one advise me if there is an object in .net that can be used to get a list or references to all objects that are currently in scope for an object. For example if the code is currently executing in a method, what objects declared in this method are currently instanciated and alive and what objects that are decla...

javascript object literal pattern with multiple instances

I have developed a little javscript widget to turn some nested <ul> blocks into a windows explorer style browser. I have recently learnt about the object literal pattern and decided to give it a go, so the organisation of my code is something like this: var myExplorer = { init : function(settings) { myExplorer.config = { ...

comparing two objects by two properties

How to sort two objects in a list by using two properties one by ascending and the other by descending order. when linq is used it says i need to implement IComparer interface but not sure how to compare two objects by using two properties at once. Say Person class by Name ascending and Age descending. ...