Browse Source

Add factory method that returns data with blank C string

master
achmizs 10 years ago
parent
commit
04f57f59ef
2 changed files with 10 additions and 0 deletions
  1. 5
    0
      NSData+SA_NSDataExtensions.h
  2. 5
    0
      NSData+SA_NSDataExtensions.m

+ 5
- 0
NSData+SA_NSDataExtensions.h View File

@@ -87,4 +87,9 @@
*/
@property (readonly) NSData *SA_dataWithUnterminatedByteString;

/** Returns an NSData object containing a blank C string (i.e. a byte sequence
of length 1, containing the null character '\0').
*/
+(NSData *)dataWithBlankCString;

@end

+ 5
- 0
NSData+SA_NSDataExtensions.m View File

@@ -75,4 +75,9 @@
}
}

+(NSData *)dataWithBlankCString
{
return [NSData dataWithBytes:"\0" length:1];
}

@end

Loading…
Cancel
Save