Latest 0.2
License BSD
Platforms ios 6.0, osx 10.9, requires ARC

NSScanner for NSData and files

MKDataScanner is for raw data, what NSScanner is for NSString. Because files are scanned as streams, large files can be scanned with minimum memory usage. Dedicated data providers for files and NSData.


  • NSScanner like interface.
  • Scan stream of file data for low memory usage.



pod 'MKDataScanner'


Scan file for sequence of bytes {0…8}

UInt8 bytes[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
NSData *searchData = [NSData dataWithBytes:bytes length:sizeof(bytes)]

MKDataScanner *scanner = [MKDataScanner scannerWithFileURL:@"/path/file.dat"];
NSData *scannedData = nil;
if ([scanner scanUpToData:searchData intoData:&scannedData]) {
    NSLog(@"scanned data: %@",scannedData);

With convenience function scanUpToBytes

UInt8 bytes[] = {0x03, 0x04, 0x05, 0x06};
[dataScanner scanUpToBytes:&bytes length:sizeof(bytes) intoData:nil];

Scan for integer

NSInteger integer;
if ([scanner scanInteger:&integer]) {
    NSLog(@"integer: %@",integer);


Marcin Krzy┼╝anowski @krzyzanowskim

Latest podspec

    "name": "MKDataScanner",
    "version": "0.2",
    "summary": "NSScanner for NSData and files.",
    "description": "MKDataScanner is for raw data, what NSScanner is for NSString.",
    "homepage": "",
    "license": {
        "type": "BSD",
        "file": "LICENSE.txt"
    "source": {
        "git": "",
        "tag": "0.2"
    "authors": {
        "Marcin Krzyu017canowski": "[email protected]"
    "social_media_url": "",
    "platforms": {
        "ios": "6.0",
        "osx": "10.9"
    "ios": {
        "header_dir": "MKDataScanner"
    "osx": {
        "header_dir": "MKDataScanner"
    "source_files": "MKDataScanner/*.{h,m}",
    "public_header_files": "MKDataScanner/*.h",
    "requires_arc": true

Pin It on Pinterest

Share This