I have a UITextField called txtDiscount
It has a value in it: txtDiscount.text == 2.3 //for example
I've tried:
float test = (NSNumber *)txtDiscount.text;
And it compiles, but at runtime breaks down.
Unacceptable type of value for attribute: property = ..."; desired type = NSNumber; given type = NSCFString; value = .
How can I ...
This is more of a theory question, then any actual code.
I understand that if you declare a variable
int i; then it sets aside 4 bytes in memory for the integer i.
I understand if you use malloc to create your memory as well.
I am curious how memory is handled when you do something like
int x;
int y;
double z;
z = (float)x/(float)y;
...
As I understand it, what makes dynamic cast different from a static cast is its use of RTTI, and the fact that it fails if the dynamic type of a variable- when casting from base to derived- does not fit. But why does the class have to be polymorphic for that to be done if we have the RTTI anyway?
EDIT: Since there was some confusion abo...
Is it possible to "upcast" from a generic class based on T, into a generic class based on something more general than T?
For instance, say I have a class named Derived that inherits from a class named Base. Can I ever do something like this:
List<Derived> der = new List<Derived>();
List<Base> bas = (List<Base>) der;
Or, using interfa...
When can a certain object be cast into another object? Does the casted object have to be a subtype of the other object? I'm trying to figure out the rules...
Edit: I realized that I didn't explain my issue at all: basically I am casting an object to an interface type. However, at run-time, I get a java.lang.ClassCastException. What n...
I would like to know the rules specified by the C++ language standard for situations like:
long x = 200;
short y = static_cast<short>(x);
Is y guaranteed to be 200, or does the standard leave this up to the implementation to decide? How well do various compilers adhere to the standard?
...
I am trying to set a Core Data attribute but am getting incompatible type errors. I have a float attribute in a Core Data entity on iPhone 3.0. Core Data auto-generates an interface for a managed data object that provides property access to it:
@property (nonatomic, retain) NSNumber * volume;
and an implementation for it:
@dynamic vo...
I was wondering why the sort method of the Arrays class is asking for a parameter of type Object[]. Why the parameter is not of type Comparable[]. If you don't pass a Comparable[] it's generating a ClassCastException.
Why ... public static void sort(Object[] a) and not public static void sort(Comparable[] a) ?
Thanks
...
Lets say I have 4Byte integer and I want to cast it to 2Byte short integer. Am I right that in both (little and big endian) short integer will consist of 2 least significant bytes of this 4Byte integer?
Second question:
What will be the result of such code in little endian and big endian processor?
int i = some_number;
short s = *(...
Hi All!
I am having trouble with my GridView in ASP.NET, which is listing a few rows of documents. Some of the rows (i.e. documents) are unpaid and need a shopping icon, which takes the clicker to another page completely. Other rows need no icon since they are paid.
This is what I have so far, although HyperLink is throwing an error s...
When I cast to Boolean (using (bool)), is there a built in way to get PHP to actually return the constants true or false. At the moment I'm getting 1 or blank, which evaluate to true and false respectively.
I want the value returned for clearer semantics. However, if I can't get it, I'll just settle with 1 and blank.
Update
I've reali...
I've run into an issue which I'm not sure if I can get round or not. My library and another library both provide an API for a particular type of data and I've now written an interop library that can sit between the two libraries and convert data freely between them which works great.
BUT I've now tried to write a small demo app of acce...
What I'm doing is looking up a value for a particular field in the hashtable. The object can be a handful of primitive types who's value is destined to be put inside XML but it comes out of the hashtable as an object. So I have the problem of needing to decide what the type is, cast it up and then use that types ToString. It would be nic...
How would you convert / cast an xmlChar* to char* from the libxml2 library? Thanks.
...
In my RubyCocoa project I am passing a block as a callback function, one of whose parameters is declared as type void *. I know that that the actual type is char *[]. My block is receiving an instance of ObjcPtr but I have been unable to access all elements within the array. The array's size is known, and passed in via another parameter....
I'm having trouble getting the following code to work correctly. Using an online IEEE-754 converter, I wrote out (by hand) to the testData.txt file that is read with the bit string that should signify the floating point number 75.5; the actual cout.write does show that the bit string is as I expect as well. However, when I try to coerc...
I have a constructor of the form:
MyClass(int a, int b, int c);
and it gets called with code like this:
MyClass my_object(4.0, 3.14, 0.002);
I would like to prevent this automatic conversion from double to int, or at least get warnings at compile time.
It seems that the "explicit" keyword does not work in these case, right?
...
Hi,
I need to convert the following c code (to calculate checksum for a file) to python. I had written, the corresponding code in python but the result didn't match the c version. The problem was that python autmatically promotes int to long whenever overflow occurs and this results in wrong checksums.
Any idea how to overcome this pro...
I'm brand new to C++/CLI and I am attempting to convert a native C++ GUID to my C++/CLI Guid^. When attempting my conversion:
BlockInfo^ blockInfo = gcnew BlockInfo();
blockInfo->BlockFilterGuid = ba.BlockAllFilter.subLayerKey;
...I recieve the following error:
error C2440: '=' : cannot convert from 'GUID' to 'System::Guid ^'
I...
I have something like this going on in my Java program:
void f(Object o) {
g(o);
}
<T extends MySuperClass & MyInterface> void g(T x) {
...;
}
How can I cast o so that this works? There seems to be no way to specify both a base class and an interface in variable declarations without using generics. I don't think generics will...