creating new object throws copywithzone unrecognized selector error in iOS

I have a simple object that looks like this:

#import <Foundation/Foundation.h>
#import <Parse/Parse.h>

@class MyUser;

@interface MyCycle : NSObject

@property (nonatomic, copy) NSNumber *myNumber;
@property (nonatomic, strong) MyUser *user;
@property (nonatomic, strong) NSArray *data;


Here is the implementation:

#import "MyCycle.h"

@implementation MyCycle


Here is the user object:

#import <Foundation/Foundation.h>
#import <Parse/Parse.h>

@interface MyUser : NSObject

@property (nonatomic, copy) NSString *usersName;
@property (nonatomic, copy) NSString *gender;
@property (nonatomic, copy) NSString *email;
@property (nonatomic, copy) NSString *password;
@property (nonatomic, copy) NSString *phoneNumber;
@property (nonatomic, strong) UIImage *profileImage;
@property (nonatomic, strong) PFFile *profileImageFile;


I allocate this object and populate it with the following:

MyCycle *cycle = [[MyCycle alloc] init];
        cycle.myNumber = @1; = [[NSArray alloc]init];

I get the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyCycle copyWithZone:]: unrecognized selector sent to instance

Why is this happening and how can I fix it?


Somewhere in your code, you have a code that attempts to copy an MyCycle instance. Perhaps you use an object as a key to a dictionary? If you wish to continue with this behavior, you need to implement the NSCopying protocol for your class.

one of a reason, that this error could happen is The name of the variable you declare or your custom class is already used by the iOS SDK. You can say it’s a keyword. And the variable name can never be a keyword because it confuses your XCode (Objective C Compiler).

I know this has been answered for a while but for posterity here is an additional one that may be the why. Check your bindings. This also will happen if you accidentally bind the controller in Interface Builder and the UI control tries to use the actual controller as a string or other value type which causes the copyWithZone: to be issued.

For instance if File's Owner has a nested controller and you accidentally bind to innerController instead of

It's old question but probably you haven't @synthesized properties 'data', 'myNumber'. In other words you have no setter for those properties.

Need Your Help

Cocos2d - scale up a sprite animation on retina device

ios animation cocos2d-iphone ccsprite sprite-sheet

I have a sprite animation that is scaled correctly on the iPad, but appears at half-size on the iPad retina (the images are 1024px wide and 20px tall, and should stretch across the entire screen wh...

Java change worker threads amount

java multithreading threadpool

I am using ExecutorService to create a fixed thread pool and start several worker threads which listen for something to happen and then do their jobs.