Skip to content

Commit

Permalink
Add alternate initializers so I can create a CDFatFile in code, for t…
Browse files Browse the repository at this point in the history
…esting.
  • Loading branch information
nygard committed Sep 18, 2012
1 parent b632df2 commit 1ca697c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
4 changes: 3 additions & 1 deletion Source/CDFatFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

@interface CDFatFile : CDFile

@property (readonly) NSArray *arches;
@property (readonly) NSMutableArray *arches;
@property (nonatomic, readonly) NSArray *archNames;

- (void)addArchitecture:(CDFatArch *)fatArch;

@end
25 changes: 20 additions & 5 deletions Source/CDFatFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@

@implementation CDFatFile
{
NSArray *_arches;
NSMutableArray *_arches;
}

- (id)init;
{
if ((self = [super init])) {
_arches = [[NSMutableArray alloc] init];
}

return self;
}

- (id)initWithData:(NSData *)data filename:(NSString *)filename searchPathState:(CDSearchPathState *)searchPathState;
Expand All @@ -30,17 +39,15 @@ - (id)initWithData:(NSData *)data filename:(NSString *)filename searchPathState:
return nil;
}

NSMutableArray *arches = [[NSMutableArray alloc] init];
_arches = [[NSMutableArray alloc] init];

header.nfat_arch = [cursor readBigInt32];
//NSLog(@"nfat_arch: %u", header.nfat_arch);
for (NSUInteger index = 0; index < header.nfat_arch; index++) {
CDFatArch *arch = [[CDFatArch alloc] initWithDataCursor:cursor];
arch.fatFile = self;
[arches addObject:arch];
[_arches addObject:arch];
}
_arches = [arches copy];
//NSLog(@"arches: %@", _arches);
}

return self;
Expand Down Expand Up @@ -133,4 +140,12 @@ - (NSArray *)archNames;
return archNames;
}

#pragma mark -

- (void)addArchitecture:(CDFatArch *)fatArch;
{
fatArch.fatFile = self;
[self.arches addObject:fatArch];
}

@end
6 changes: 0 additions & 6 deletions Source/CDFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ + (id)fileWithContentsOfFile:(NSString *)filename searchPathState:(CDSearchPathS
return machOFile;
}

- (id)init;
{
[NSException raise:@"RejectUnusedImplementation" format:@"-initWithData: is the designated initializer"];
return nil;
}

- (id)initWithData:(NSData *)data filename:(NSString *)filename searchPathState:(CDSearchPathState *)searchPathState;
{
if ((self = [super init])) {
Expand Down

0 comments on commit 1ca697c

Please sign in to comment.