軽く衝撃を受けてます。自前で変換コードを書いていたような気が..
以下、転載
- (unsigned int)intFromHexString:(NSString *) hexStr { unsigned int hexInt = 0; // Create scanner NSScanner *scanner = [NSScanner scannerWithString:hexStr]; // Tell scanner to skip the # character [scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@"#"]]; // Scan hex value [scanner scanHexInt:&hexInt]; return hexInt; }
こうなる。
関連)