// 先从txt文件中获取姓和名数组

- (void)getNames{

NSString *resourcePath1 = [[NSBundle mainBundle] pathForResource:@"FirstName" ofType:@"txt"];

NSString *resourcePath2 = [[NSBundle mainBundle] pathForResource:@"LastName" ofType:@"txt"];

NSLog(@".....%@",resourcePath1);

NSLog(@">>>> %@",resourcePath2);

NSData *firstData = [NSData dataWithContentsOfFile:resourcePath1];

NSData *lastData  = [NSData dataWithContentsOfFile:resourcePath2];

NSString *firstStr= [[NSMutableString alloc] initWithData:firstData encoding:NSUTF8StringEncoding];

NSString *lastStr = [[NSMutableString alloc] initWithData:lastData encoding:NSUTF8StringEncoding];

char *Cstring = "\n";    //分割符

NSString *separatedString = [NSString stringWithUTF8String:Cstring];

_FirstNames = [firstStr componentsSeparatedByString:separatedString];

_LastNames  = [lastStr  componentsSeparatedByString:separatedString];

}

// 点击显示姓名

NSString *firstName = [_FirstNames objectAtIndex:arc4random()%(_FirstNames.count)];

NSString *lastName  = [_LastNames  objectAtIndex:arc4random()%(_LastNames.count)];

[_nameLabel setText:[NSString stringWithFormat:@"%@%@",firstName,lastName]];

最新文章

  1. 项目中angular js的接口url统一管理
  2. 软工实践——github文件整理
  3. 未定义标识符string
  4. 关于eclipse中MAVEN WEB工程中编译问题
  5. 学习 BigInteger
  6. HTTP Status 404–/webDemo/hello
  7. 动态 SQL
  8. ubuntu zend-eclipse-php debugger调试
  9. Android 自定义View (四) 视频音量调控
  10. goahead webserver源码分析
  11. EF使用时异常:对一个或多个实体的验证失败。有关详细信息
  12. Asp.Net MVC5入门学习
  13. match in shell scripts
  14. JavaScript的数组实现队列与堆栈的方法
  15. Codeforces 812E Sagheer and Apple Tree
  16. 自定义 ThreadPoolExecutor 处理线程运行时异常
  17. 3D视图的2D展示
  18. PHP实用代码片段(三)
  19. mysql导出长数字到excel避免显示为科学记数法 解决方法
  20. python魔法方法:__getattr__,__setattr__,__getattribute__

热门文章

  1. windows异常调用顺序
  2. Windows phone 8 学习笔记(4) 应用的启动(转)
  3. axis2 部署webservice
  4. ADO访问Access数据库错误解决心得随笔
  5. 在信号处理函数中调用longjmp
  6. jQuery中$.ajax()和$.getJson()同步处理详解
  7. js-布尔值
  8. ES6还是ES2015?
  9. excel上传和下载
  10. Hive中典型的表内数据除重写法