Let’s say we have a class with an NSTimeInterval property:
@interface MyClass : NSObject {
NSTimeInterval timeSpent;
}
@property (assign) NSTimeInterval timeSpent;
I can then get the type of the property like so:
const char * type = property_getAttributes(class_getProperty([MyClass class], "timeSpent"));
…where type would be something like: Td, VtimeSpan with “d” indicating that it’s a double (which is normal since docs says typedef double NSTimeInterval)
Is there anything I can do in order to find out that the timeSpent property was initially declared as a NSTimeInterval?
Thanks !
You can’t.
NSTimeIntervalis atypedefofdouble, which means that it is exactly the same type with a new name. This is convenient for writing self-documenting code, but it doesn’t change anything about the type. (It also allows the underlying type to be changed while remaining source-compatible; they could changeNSTimeIntervalto be an alias offloator_Complex doubleor something else entirely, and your code wouldn’t need to care.)Is there a reason you care? Are you trying to write some generic code that treats time intervals differently than regular numbers? What’s the end goal you have?