【发布时间】:2013-10-03 06:13:06
【问题描述】:
您好,我是 iOS 的初学者在我的一项活动中,我有 NSString 并想转换为十六进制格式
NSString *str= 131003112444371;
long long decimalRepresentation = 131003112444371;
NSLog(@"date %llx",decimalRepresentation);
NSLog(@"Hex value of char is 0x%02llx",decimalRepresentation);
我正在使用这个然后得到结果 0x772589fb51d3 我想提取这个没有 772589fb51d3 当我为此使用这些线时....
NSString *str1=[NSString stringWithFormat:@"%llu",decimalRepresentation];
NSLog(@"str %@",str1);
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"0x"];
str1 = [[str1 componentsSeparatedByCharactersInSet:doNotWant]componentsJoinedByString:@""];
NSLog(@"%@", str1); // => foobarbazfoo
但是这一行再次将此十六进制值转换为字符串我不提取此值 0x772589fb51d3 为 772589fb51d3 .请帮助我.... 提前致谢
【问题讨论】:
-
[请通过以下链接可能会对您有所帮助][1] [1]:stackoverflow.com/questions/9888456/ios-convert-hex-value
-
我想把nsstring转成十六进制格式
-
这个问题已经被问过很多次了。在发布您的问题之前,您是否尝试过查看 SO?
-
我已经检查过了......如果你有任何答案,那么请不要浪费时间
标签: iphone ios objective-c