Trouble Copying custom class initialization
Posted
by Parad0x13
on Stack Overflow
See other posts from Stack Overflow
or by Parad0x13
Published on 2010-05-22T01:58:00Z
Indexed on
2010/05/22
2:00 UTC
Read the original article
Hit count: 227
I have a custom class of type NSObject that contains a single NSMutableArray. This class is called Mutable2DArray and is designed to emulate a 2 dimensional array of type NSMutableArray. There is a custom init method - (id)initWithX:(int)x Y:(int)y that asks for the dimensions for the array and allocates the required arrays within the only array the class owns.
My issue is when I try to copy an instance of Mutable2DArray I get an error saying the copyWithZone is an unrecognized selector. I thought copy was a base method of NSObject so I'm confused why I cant create a copy of the instance like this:
Mutable2DArray *Array1 = [[Mutable2DArray alloc] initWithX:10 Y:10];
Mutable2DArray *Array2 = [Array1 copy];
Am I missing something so obvious here?
© Stack Overflow or respective owner