随机产生一个汉字

2015-08-30 0 979
随机产生一个汉字
        NSInteger i =  arc4random()%(0x9fa5-0x4e00 + 1) + 0x4e00;
        NSString * unicodeStr = [NSString stringWithFormat:@"\"\\U%lx\"", i];
        NSData *tempData = [unicodeStr dataUsingEncoding:NSUTF8StringEncoding];
        NSString* randomStr = [NSPropertyListSerialization propertyListFromData:tempData
                                                              mutabilityOption:NSPropertyListImmutable
                                                                        format:NULL
                                                              errorDescription:NULL];
        NSLog(@"%@", randomStr);

遇见资源网 objective-c 随机产生一个汉字 http://www.ox520.com/18061.html

下一篇: 时间戳
常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务