I have just created an Extension
for NSString
class inside a Category
class
#import "NSString+Name.h"
@interface NSString(Name)
@property (nonatomic, retain) NSString *var;
@end
But when i am trying to access that private variable inside the category class the app crashes and gives the error.
@implementation NSString (Name)
- (NSString*)newString{
[self setVar:@"Its a new string"]; // Crashes here
NSLog(@"name = %@",self.var);
return self.var;
}
@end
Reason of crash
unrecognized selector sent to instance 0x1023641c8 2015-05-25 11:12:49.246 Tute[710:14433] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString setVar:]: unrecognized selector sent to instance 0x1023641c8'
If i am able to assign values in that variable then why its saying unrecognized selector