Sample code for 30+ languages & platforms
Objective-C

Split File into Chunks

Demonstrates how to split a file into chunks.

Chilkat Objective-C Downloads

Objective-C
#import <CkoFileAccess.h>
#import <NSString.h>

BOOL success = NO;

CkoFileAccess *fac = [[CkoFileAccess alloc] init];

//  Any type of file may be split.  It doesn't matter if it's
//  a binary file or a text file.
NSString *fileToSplit = @"qa_data/hamlet.xml";

NSString *partPrefix = @"hamlet";
NSString *partExtension = @"part";
int maxChunkSize = 50000;
NSString *destDirPath = @"qa_output";

//  Splits hamlet.xml into hamlet1.part, hamlet2.part, ...
//  Output files are written to the current working directory.
//  Each chunk will be 50000 bytes except for the last which
//  will be the remainder.
success = [fac SplitFile: fileToSplit partPrefix: partPrefix partExtension: partExtension partSize: [NSNumber numberWithInt: maxChunkSize] destDir: destDirPath];

if (success == YES) {
    NSLog(@"%@",@"Success.");
}
else {
    NSLog(@"%@",fac.LastErrorText);
}