Skip to content
Browse files

proper init method style

  • Loading branch information...
1 parent 31be4e2 commit 79d7eb1db1a7c793e62aba4edaf3ed1a9fe3e2da @mikeabdullah mikeabdullah committed Jan 21, 2012
Showing with 34 additions and 27 deletions.
  1. +4 −2 DOM/KSXMLWriterDOMAdaptor.m
  2. +6 −5 KSHTMLWriter.m
  3. +4 −2 KSStringXMLEntityEscaping.m
  4. +8 −6 KSXMLAttributes.m
  5. +12 −12 KSXMLWriter.m
View
6 DOM/KSXMLWriterDOMAdaptor.m
@@ -31,8 +31,10 @@ @implementation KSXMLWriterDOMAdaptor
- (id)initWithXMLWriter:(KSXMLWriter *)writer;
{
- [self init];
- _writer = [writer retain];
+ if (self = [self init])
+ {
+ _writer = [writer retain];
+ }
return self;
}
View
11 KSHTMLWriter.m
@@ -51,11 +51,12 @@ @implementation KSHTMLWriter
- (id)initWithOutputWriter:(id <KSWriter>)output;
{
- [super initWithOutputWriter:output];
-
- [self setDocType:KSHTMLWriterDocTypeHTML_5];
- _IDs = [[NSMutableSet alloc] init];
- _classNames = [[NSMutableArray alloc] init];
+ if (self = [super initWithOutputWriter:output])
+ {
+ [self setDocType:KSHTMLWriterDocTypeHTML_5];
+ _IDs = [[NSMutableSet alloc] init];
+ _classNames = [[NSMutableArray alloc] init];
+ }
return self;
}
View
6 KSStringXMLEntityEscaping.m
@@ -90,8 +90,10 @@ @implementation KSEscapedXMLEntitiesWriter
- (id)initWithOutputXMLWriter:(id <KSWriter>)output; // designated initializer
{
- [self init];
- _output = [output retain];
+ if (self = [self init])
+ {
+ _output = [output retain];
+ }
return self;
}
View
14 KSXMLAttributes.m
@@ -17,17 +17,19 @@ @implementation KSXMLAttributes
- (id)init;
{
- [super init];
- _attributes = [[NSMutableArray alloc] initWithCapacity:2];
+ if (self = [super init])
+ {
+ _attributes = [[NSMutableArray alloc] initWithCapacity:2];
+ }
return self;
}
- (id)initWithXMLAttributes:(KSXMLAttributes *)info;
{
- self = [super init]; // call super, so _attributes is still nil
-
- _attributes = [info->_attributes mutableCopy];
-
+ if (self = [super init]) // call super, so _attributes is still nil
+ {
+ _attributes = [info->_attributes mutableCopy];
+ }
return self;
}
View
24 KSXMLWriter.m
@@ -85,18 +85,18 @@ @implementation KSXMLWriter
- (id)initWithOutputWriter:(id <KSWriter>)output; // designated initializer
{
- [super initWithOutputWriter:output];
-
- _attributes = [[KSXMLAttributes alloc] init];
- _openElements = [[NSMutableArray alloc] init];
-
- // Inherit encoding where possible
- _encoding = ([output respondsToSelector:@selector(encoding)] ?
- [(KSXMLWriter *)output encoding] :
- NSUTF8StringEncoding);
-
- _contentsProxy = [KSXMLElementContentsProxy alloc]; // it's a proxy without an -init method
-
+ if (self = [super initWithOutputWriter:output])
+ {
+ _attributes = [[KSXMLAttributes alloc] init];
+ _openElements = [[NSMutableArray alloc] init];
+
+ // Inherit encoding where possible
+ _encoding = ([output respondsToSelector:@selector(encoding)] ?
+ [(KSXMLWriter *)output encoding] :
+ NSUTF8StringEncoding);
+
+ _contentsProxy = [KSXMLElementContentsProxy alloc]; // it's a proxy without an -init method
+ }
return self;
}

0 comments on commit 79d7eb1

Please sign in to comment.
Something went wrong with that request. Please try again.