Objective-C – Can I use nsdecimalnumber anywhere in the expected NSNumber?

NSDecimalNumber is a subclass of NSNumber. As far as I know, it implements all NSNumber methods expected by NSNumber instances.

In view of this, is it possible? Provide NSDecimalNumbers to any code that expects NSNumber?

The only possible problem may be that the check parameter is the code of an NSNumber instance, but since NSNumber is a class cluster, such code must check that the instance is a subclass of NSNumber, and the NSDecimalNumber instance should pass its test.

p>

Yes.

The only possible issue might be code that checks that an argument is an instance of NSNumber, but since NSNumber is a class-cluster, code like this would have to check that the instance is a subclass of NSNumber, and NSDecimalNumber instances should pass the same tests.

This is isKindOfClass: here, although you may prefer to test whether the object responds to messages like integerValue.

NSDecimalNumber is a subclass of NSNumber. As far as I know, it implements all the NSNumber methods expected by NSNumber instances.

In view of this, is it possible to provide NSDecimalNumbers to any code that expects NSNumber?

The only possible problem may be that the check parameter is the code of an NSNumber instance, but since NSNumber is a class cluster, such code must check that the instance is a subclass of NSNumber, and the NSDecimalNumber instance should pass its test.

p>

Yes.

The only possible issue might be code that checks that an argument is an instance of NSNumber, but since NSNumber is a class-cluster, code like this would have to check that the instance is a subclass of NSNumber, and NSDecimalNumber instances should pass the same tests.

This is the isKindOfClass: here, although you may prefer to test whether the object responds to a message like integerValue.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2192 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.