characterSetWithBitmapRepresentation:
バイナリデータから文字セットを作って返します
+(NSCharacterSet *)characterSetWithBitmapRepresentation:(NSData *)data:
解説
バイナリデータから文字セットを作って返します。
返り値
( NSCharacterSet * )
文字セット
引数
( NSData * )data
データ
フレームワーク
Foundation
クラス
NSCharacterSet
Class Methods
使用可能
10.0
参照
- bitmapRepresentation
+ characterSetWithContentsOfFile:
例文
//testWritecharset.bitmapのファイルが警告無しで下記変わるので注意!!!! #import "SetImage.h" @implementation SetImage - (IBAction)set:(id)sender { NSString *path = @"~/testWritecharset.bitmap";//ユーザーディレクトリのトップのtestWritecharset.dataというファイルへ NSData *bData ; NSData *readData ; unichar currentChar ; NSCharacterSet *chrSet; NSCharacterSet *chrSet2; int i; chrSet = [NSCharacterSet uppercaseLetterCharacterSet] ; bData = [chrSet bitmapRepresentation] ; //データ書き出し if ([bData writeToFile:[path stringByExpandingTildeInPath] atomically:YES]){ NSLog(@"YES"); }else{ NSLog(@"NO"); } //データ読み込み readData = [NSData dataWithContentsOfFile:[path stringByExpandingTildeInPath]]; chrSet2 = [NSCharacterSet characterSetWithBitmapRepresentation:readData]; for ( i=1 ; i<=127 ; i++){ currentChar = (unichar)i; if ([chrSet2 characterIsMember:currentChar]) { [tv insertText:[NSString stringWithFormat:@"%c",currentChar]]; } } } @end