Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Code style consistency.

  • Loading branch information...
commit 17cc2f957a27964ff654c8f0290cfc18b4ea0e67 1 parent 8fcd59b
@nfarina authored
Showing with 4 additions and 7 deletions.
  1. +1 −1  SMXMLDocument.h
  2. +3 −6 SMXMLDocument.m
View
2  SMXMLDocument.h
@@ -24,7 +24,7 @@
// SMXMLDocument is a very handy lightweight XML parser for iOS.
-extern NSString *const SMXMLDocumentErrorDomain;
@0xced
0xced added a note

Why removing the const? It is everywhere through the Cocoa frameworks for NSString constants.

@nfarina Owner
nfarina added a note

The const doesn't seem to be correctly applied in this situation, I'm not 100% on C syntax but when I move the const to the beginning of the line (which is where I always assumed that keyword would go) I then get a compiler error about passing a const string as an argument to +errorWithDomain which expects a non-const NSString. So you could add a cast there as well but then it gets a little silly.

@nfarina Owner
nfarina added a note

Nevermind, I'm an idiot, I see some examples in Apple's header files and you're correct. Will fix =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+extern NSString *SMXMLDocumentErrorDomain;
@class SMXMLDocument;
View
9 SMXMLDocument.m
@@ -1,9 +1,8 @@
#import "SMXMLDocument.h"
-NSString *const SMXMLDocumentErrorDomain = @"SMXMLDocumentErrorDomain";
+NSString *SMXMLDocumentErrorDomain = @"SMXMLDocumentErrorDomain";
-static NSError * SMXMLDocumentError(NSXMLParser *parser, NSError *parseError)
-{
+static NSError *SMXMLDocumentError(NSXMLParser *parser, NSError *parseError) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObject:parseError forKey:NSUnderlyingErrorKey];
NSNumber *lineNumber = [NSNumber numberWithInteger:parser.lineNumber];
NSNumber *columnNumber = [NSNumber numberWithInteger:parser.columnNumber];
@@ -17,10 +16,8 @@ @implementation SMXMLElement
@synthesize document, parent, name, value, children, attributes;
- (id)initWithDocument:(SMXMLDocument *)aDocument {
- self = [super init];
- if (self) {
+ if ([super init])
@0xced
0xced added a note

This is not consistent with -[SMXMLDocument initWithData:error:]

Also, reading self = [stupid init];, self = [super init] debate and What does it mean when you assign [super init] to self? might convince you to assign self ;-)

@nfarina Owner
nfarina added a note

Sigh, yes, I've read all those articles debating the proper use pattern of [super init], and never found a satisfactory explanation of a case I would ever find myself in where the self pointer would not be correctly set up already. So in my own code I've been doing if ([super init]) since the new LLVM complains about a missing set of parens if it's the traditional if (self = [super init]) and I don't want to add the extra parens everywhere.

But, I'll probably get hassled about it more by others if I do it here so I'll change it back to the "accepted" way. I just hate burning all those LOC in init methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
self.document = aDocument;
- }
return self;
}
Please sign in to comment.
Something went wrong with that request. Please try again.