I have created an object of type NSMutableArray
#import <Foundation/Foundation.h>
@interface MyCustomObject : NSMutableArray
{
}
@end
in one of my classes, I delcare an instance:
MyCustomObject *myObj = [[NSMutableArray alloc] init];
But xcode is giving a warning on this line: Incompatible pointer types initializing 'MyCustomObject *' with an expression of type 'NSMutableArray *'
Any idea what is wrong? It works fine, but just wondering why it is throwing a warning and how to resolve it?
You can assign a child class to a variable typed as its super-class, but you cannot assign a super-class to a child class variable.
So, you'd want to:
MyCustomObject *myObj = [[MyCustomObject alloc] init];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With