views:

46

answers:

1

I am trying to retrieve the value (how far along it is) of a Determinate NSProgressIndicator. I have tried …

NSInteger *bValue = [progressIndicator doubleValue];

But it gives an error saying Incompatible types in initialization. So how do I retrieve the value of the Progress Indicator?

+2  A: 

An NSInteger is not an object type, it is simply a typedef for an int or long (dependent on whether your application is 32 or 64-bit):

#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
#else
typedef int NSInteger;
#endif

(From the docs)

Therefore, you can write it as:

NSInteger bValue = [progressIndicator doubleValue];

You are receiving an error because you are declaring bValue as a pointer to an NSInteger, yet trying to initialize it with a double value.

Perspx
Ah, I see know why I get the error. So what should I put instead of NSInteger?
Joshua
You can leave it as `NSInteger` if you want, you just need to omit the *. It depends on the level of precision you want – if you only need to know the integer value of the progress indicator, use `NSInteger`. If you want a higher amount of precision, use `float` or `double`.
Perspx
I doesn't need to be that precise so `NSInteger` should be ok. Thanks!
Joshua