Permalink
Browse files

NSCopying implementation

  • Loading branch information...
1 parent 606920b commit a11085b456d00f892e4dd8648efadbcae362d352 Valeriy Dyryavyy committed Oct 15, 2012
Showing with 21 additions and 1 deletion.
  1. +1 −1 SOCKit.h
  2. +20 −0 SOCKit.m
View
@@ -95,7 +95,7 @@
* performSelector:onObject:sourceString: is provided a selector with "init" as a prefix
* and object is a Class. E.g. [GithubUser class].
*/
-@interface SOCPattern : NSObject {
+@interface SOCPattern : NSObject <NSCopying> {
@private
NSString* _patternString;
NSArray* _tokens;
View
@@ -54,6 +54,10 @@ - (NSString *)string;
///////////////////////////////////////////////////////////////////////////////////////////////////
@interface SOCPattern()
+@property (nonatomic, retain) NSString *patternString;
+@property (nonatomic, retain) NSArray *tokens;
+@property (nonatomic, retain) NSArray *parameters;
+
- (void)_compilePattern;
@end
@@ -66,6 +70,22 @@ @implementation SOCPattern
///////////////////////////////////////////////////////////////////////////////////////////////////
+- (id)copyWithZone:(NSZone *)zone
+{
+ id copy = [[[self class] alloc] init];
+
+ if (copy)
+ {
+ [copy setPatternString:[[self.patternString copy] autorelease]];
+ [copy setTokens:[[self.tokens copy] autorelease]];
+ [copy setParameters:[[self.parameters copy] autorelease]];
+ }
+
+ return copy;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)dealloc {
[_patternString release]; _patternString = nil;
[_tokens release]; _tokens = nil;

0 comments on commit a11085b

Please sign in to comment.