Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

minor changes to remove a few warnings #76

Merged
merged 2 commits into from

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
Jonathan 'Wolf' Rentzsch rentzsch referenced this pull request from a commit
Jonathan 'Wolf' Rentzsch [FIX] Over-release committed in #76 fe6e1d7
Sean Roehnelt seanroehnelt referenced this pull request from a commit in kiha/mogenerator
Jonathan 'Wolf' Rentzsch [FIX] Over-release committed in #76 5056e68
ddrccw ddrccw referenced this pull request from a commit in ddrccw/mogenerator
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
View
@@ -418,7 +418,7 @@ - (id)initWithExpressions:(NSArray *)list
{
self = [super init];
if ( self ) {
- expressions = [list retain];
+ expressions = [list mutableCopy];
}
return self;
}
19 MiscMerge/MiscMergeTemplate.m
View
@@ -129,13 +129,25 @@ + (NSString *)defaultEndDelimiter
return self;
}
+/* helper method to load string contents of filenames */
+- (NSString *) contentsOfFileWithName:(NSString *)filename {
+ NSError *error = nil;
+ NSString *fileString = [NSString stringWithContentsOfFile:filename
+ encoding:NSASCIIStringEncoding
+ error:&error];
+
+ if (error != nil) {
+ NSLog(@"%@: Could not read template file %@ because %@", [self class], filename, [error localizedDescription]);
+ }
+ return fileString;
+}
+
/*"
* Loads the contents of filename, then calls -#initWithString:.
"*/
- initWithContentsOfFile:(NSString *)filename
{
- NSString *fileString = [[[NSString alloc] initWithContentsOfFile:filename] autorelease];
- if (fileString == nil) NSLog(@"%@: Could not read template file %@", [self class], filename);
+ NSString *fileString = [self contentsOfFileWithName:filename];
return [self initWithString:fileString];
}
@@ -432,8 +444,7 @@ - (void)_addCommandString:(NSString *)commandString
"*/
- (void)parseContentsOfFile:(NSString *)filename
{
- NSString *string = [[NSString alloc] initWithContentsOfFile:filename];
- if (string == nil) NSLog(@"%@: Could not read template file %@", [self class], filename);
+ NSString *string = [self contentsOfFileWithName:filename];
[self setFilename:filename];
[self parseString:string];
[string release];
5 MiscMerge/_MiscMergeIncludeCommand.m
View
@@ -52,8 +52,9 @@ - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)tem
resolvedFilename = [template resolveTemplateFilename:filename];
+ NSError *error = nil;
if ([resolvedFilename length] > 0)
- fileString = [[[NSString alloc] initWithContentsOfFile:resolvedFilename] autorelease];
+ fileString = [NSString stringWithContentsOfFile:resolvedFilename encoding:NSASCIIStringEncoding error:&error];
if (fileString)
{
@@ -72,7 +73,7 @@ - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)tem
}
else
{
- [template reportParseError:@"%@: Could not load from file '%@'", [self class], resolvedFilename];
+ [template reportParseError:@"%@: Could not load from file '%@' because %@", [self class], resolvedFilename, [error localizedDescription]];
}
return YES;
Something went wrong with that request. Please try again.