I want to add a property to a NSString object. For this reason I want to subclass it.
I try to make something like this:
@interface MyString : NSString
@property (nonatomic) NSInteger userId;
@end
so then I can do
MyString *testString = [[MyString alloc] init];
testString = [MyString stringWithFormat:@"hello"];
testString.userId = 2;
NSLog(@"testString: %@", testString); //-> Want it to return "testString: hello"
NSLog(@"userId: %d", testString.userId); //-> Want it to return "userId: 2"
I don't know how to subclass NSString (create storage facilities, override some methods (length, characterAtIndex). Have an idea?