Coding for iOS apps, I find there is potential reason to prohibit inheriting NSNumber, NSNull, …blabla.
If I try to do this, compiler does not fail but running will crash at once without any usage info, does anyone know the reason?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Subclassing Notes
More precisely, I believe it’s because you never actually have an instance of NSNumber. Objective-C has the interesting property that the initializer of a class can actually change the object to which self points (this might actually be true of any method, but I’ve only ever heard of it being used in the init methods). I believe that NSNumber does this very thing.
See also the documentation on Class Clusters.