I have a simple question about creating multiple initialisers within an objective-c class.
Basically I have a class that represents a single row in my database (users). I currently have an initialiser which initialises the class based upon the users UserID (which is also the primary key within the database), when passed the UserID the cl...
I have a class MyClass. I am exaggerating here, but let's say MyClass has 1000 instance variables. I then create a subclass called MySubClass with all the instance variables MyClass has, plus one more.
Question: given an object MyObj of class MyClass, is there an easy way to create a corresponding object MyDerivedObj of class MySubC...
What's the best way to initialize constants or other fields in inherited classes? I realize there are many syntax errors in this example, but this is the best example to explain clearly what I am trying to do.
public abstract class Animal {
public abstract const string Name; // #1
public abstract const bool CanFly;
public abstract...
Hello,
I need to create a Set with initial values.
Set<String> h = new HashSet<String>();
h.add("a");
h.add("b");
Is there a way to do it in one command?
Thanks
...
I was trying to create a static variable to store a dictionary of images. Unfortunately, the best way I could find to initialise it was to check in each function that used the variable. Since I am creating this variable inside a category, I can't just initialise it inside the initialiser. Is there a neater way of initialising navigationB...
Hello Group,
I am working on a legacy framework. Lets say 'A' is the base-class and 'B' is the derived class. Both the classes do some critical framework initialization. FWIW, it uses ACE library heavily.
I have a situation wherein; an instance of 'B' is created. But the ctor of 'A' depends on some initialization that can only be perf...
Hello, in my ASMX WS Application_Start is called when 1st request arrives. It's kind of too late then for me. Is there any way to get it called when iisreset is done?
In http://stackoverflow.com/questions/1820770/what-is-the-right-way-to-spawn-thread-for-database-io-in-asmx-web-service I asked about preloading system data and the guys ...
I've got a problem (in Objective-C/iPhone dev) since more than one week, so I'd be really grateful if someone can help me out.
When I instantiate an object from a class that I've written, it returns me nil, but when I launch the debug mode I actually see in the init method that the attributes of self are correctly initialized and it see...
Hello, there is a error in my iPhone app. I use the CameraPicker to make and get a picture and then I give it to my methode sendPhoto, which will send the photo to TweetPhoto. Everything works great until I initialize an NSMutableDate with NSData. Here is the code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinis...
In the Load event or in the constructor after the InitializeComponent()?
or doesn't matter at all?
...
Hello. I am making an iPhone app that uses a few NSArrays. Right now I have to generate the arrays in each method. I know there has to be an more efficient way of doing this, like having the NSArrays created during initialization and then being available to all methods after that. The problem is, that when I create the NSArrays in th...
How does the following code work in C++? Is it logical?
const int &ref = 9;
const int &another_ref = ref + 6;
Why does C++ allow literal initialization for const references when the same is not permitted for non-const references? E.g.:
const int days_of_week = 7;
int &dof = days_of_week; //error: non const reference to a const objec...
I'm playing around with an eager-initializing generic singleton class. The idea is that you inherit publicly from the class like so:
class foo : public singleton<foo> { };
I've learned a lot in the process but I'm stuck right now because it's breaking my Visual Studio 2008 linker. The problem is with the static instance member and/or ...
I have a Message model class (which inherits from ActiveRecord::Base). For a particular deployment, I would like to have a separate file which modifies Message by adding a callback. So, instead of doing:
# app/models/message.rb
class Message < ActiveRecord::Base
before_save :foo
def foo
puts 'foo!'
end
end
I would like to b...
In order to better understand the startup, event queue, and methods within my application I'm trying to write a program that does two things: Play a beep at the startup and every time the user hits a button. So far it only plays when the user hits the button. I know there may be multiple ways to get the startup beep to play, but in ord...
Hi,
I have just found out that the following is not valid.
//Header File
class test
{
const static char array[] = { '1', '2', '3' };
};
Where is the best place to initialize this?
Thanks in advance;
...
My code is something like:
public class Foo {
public int a;
Bar[] bar = new Bar[10];
a = bar[0].baz;
}
public class Bar {
public int b;
public Bar () { //I tried doing away with this constructor, but that didn't
//fix anything
b = 0;
}
public int Baz () {
//do somthing
...
Possible Duplicate:
What is the difference between a definition and a declaration?
Is it correct that to declare in C is equal to define in C++?
int a; /* to declare variabel a in C */
int b = 2; /* to declare and initialize in C */
int c; // to define in C++
int d = 4; // to define and initialize in C++
...
So assume I have a class that has an init method that does something like... grabs some data off the net in xml format and parses it to initialize some of its properties. My concern is how should I handle the case where the network is down or the xml data my object receives is bad?
Normally in C i would use return values to indicate an...
As the title says, some URLs take less than a second to load in the browser, but in my cocoa app, running the following line repeatedly results in initWithContentsOfURL sometimes taking up to 30 seconds to load the URL. What may be the source of this problem?
I'm calling it like this:
NSXMLDocument* aDoc = [[NSXMLDocument alloc] initWi...