Skip to content
This repository

minor changes to remove a few warnings #76

Merged
merged 2 commits into from over 2 years ago

2 participants

Joshua Smith Jonathan 'Wolf' Rentzsch
Joshua Smith

These are very minor changes to remove a few warnings, all but one is related to the use of a deprecated method on NSString (initWithContentsOfString).

The other warning was caused by a non-mutable object being assigned to a mutable one (this was fixed with mutableCopy).

Jonathan 'Wolf' Rentzsch
Owner

Thanks! Pulled.

Jonathan 'Wolf' Rentzsch rentzsch merged commit dc55ebb into from November 22, 2011
Jonathan 'Wolf' Rentzsch rentzsch closed this November 22, 2011
Sean Roehnelt seanroehnelt referenced this pull request from a commit in kiha/mogenerator December 08, 2011
Jonathan 'Wolf' Rentzsch [FIX] Over-release committed in #76 5056e68
ddrccw ddrccw referenced this pull request from a commit in ddrccw/mogenerator December 08, 2011
Jonathan 'Wolf' Rentzsch [FIX] Over-release committed in #76 f51ee57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  MiscMerge/MiscMergeExpression.m
@@ -418,7 +418,7 @@ - (id)initWithExpressions:(NSArray *)list
418 418
 {
419 419
     self = [super init];
420 420
     if ( self ) {
421  
-        expressions = [list retain];
  421
+        expressions = [list mutableCopy];
422 422
     }
423 423
     return self;
424 424
 }
19  MiscMerge/MiscMergeTemplate.m
@@ -129,13 +129,25 @@ + (NSString *)defaultEndDelimiter
129 129
     return self;
130 130
 }
131 131
 
  132
+/* helper method to load string contents of filenames */
  133
+- (NSString *) contentsOfFileWithName:(NSString *)filename {
  134
+    NSError *error = nil;
  135
+    NSString *fileString = [NSString stringWithContentsOfFile:filename
  136
+                                                     encoding:NSASCIIStringEncoding
  137
+                                                        error:&error];
  138
+    
  139
+    if (error != nil) {
  140
+        NSLog(@"%@: Could not read template file %@ because %@", [self class], filename, [error localizedDescription]);   
  141
+    }
  142
+    return fileString;
  143
+}
  144
+
132 145
 /*"
133 146
  * Loads the contents of filename, then calls -#initWithString:.
134 147
 "*/
135 148
 - initWithContentsOfFile:(NSString *)filename
136 149
 {
137  
-    NSString *fileString = [[[NSString alloc] initWithContentsOfFile:filename] autorelease];
138  
-    if (fileString == nil) NSLog(@"%@: Could not read template file %@", [self class], filename);
  150
+    NSString *fileString = [self contentsOfFileWithName:filename];
139 151
     return [self initWithString:fileString];
140 152
 }
141 153
 
@@ -432,8 +444,7 @@ - (void)_addCommandString:(NSString *)commandString
432 444
 "*/
433 445
 - (void)parseContentsOfFile:(NSString *)filename
434 446
 {
435  
-    NSString *string = [[NSString alloc] initWithContentsOfFile:filename];
436  
-    if (string == nil) NSLog(@"%@: Could not read template file %@", [self class], filename);
  447
+    NSString *string = [self contentsOfFileWithName:filename];
437 448
     [self setFilename:filename];
438 449
     [self parseString:string];
439 450
     [string release];
5  MiscMerge/_MiscMergeIncludeCommand.m
@@ -52,8 +52,9 @@ - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)tem
52 52
 
53 53
     resolvedFilename = [template resolveTemplateFilename:filename];
54 54
 
  55
+    NSError *error = nil;
55 56
     if ([resolvedFilename length] > 0)
56  
-        fileString = [[[NSString alloc] initWithContentsOfFile:resolvedFilename] autorelease];
  57
+        fileString = [NSString stringWithContentsOfFile:resolvedFilename encoding:NSASCIIStringEncoding error:&error];
57 58
 
58 59
     if (fileString)
59 60
     {
@@ -72,7 +73,7 @@ - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)tem
72 73
     }
73 74
     else
74 75
     {
75  
-        [template reportParseError:@"%@: Could not load from file '%@'", [self class], resolvedFilename];
  76
+        [template reportParseError:@"%@: Could not load from file '%@' because %@", [self class], resolvedFilename, [error localizedDescription]];
76 77
     }
77 78
 
78 79
     return YES;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.