Changeset 3083

Show
Ignore:
Timestamp:
12/26/05 19:26:00 (3 years ago)
Author:
timothy
Message:
  • Some "for fun" NSData additions incase they are needed. (I originally thought I would need these, but worked around it.)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Additions/NSDataAdditions.h

    r3072 r3083  
    55- (NSString *) base64Encoding; 
    66- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength; 
     7 
     8- (BOOL) hasPrefix:(NSData *) prefix; 
     9- (BOOL) hasPrefixBytes:(void *) prefix length:(unsigned int) length; 
    710@end 
  • trunk/Additions/NSDataAdditions.m

    r3072 r3083  
    144144        return [NSString stringWithString:result]; 
    145145} 
     146 
     147#pragma mark - 
     148 
     149- (BOOL) hasPrefix:(NSData *) prefix { 
     150        unsigned int length = [prefix length]; 
     151        if( ! prefix || ! length || [self length] < length ) return NO; 
     152        return ( memcmp( [self bytes], [prefix bytes], length ) == 0 ); 
     153} 
     154 
     155- (BOOL) hasPrefixBytes:(void *) prefix length:(unsigned int) length { 
     156        if( ! prefix || ! length || [self length] < length ) return NO; 
     157        return ( memcmp( [self bytes], prefix, length ) == 0 ); 
     158} 
    146159@end