iOS将excel转plist
iOS将excel转plist
先把excel用Numbers打开,转换成CSV,然后新建一个工程,写下面的代码:
- (void)viewDidLoad {
[super viewDidLoad];
[self writeToPlist];
} - (void)writeToPlist {
NSString *path = [[NSBundle mainBundle] pathForResource:@"高德地图API 城市编码表 2" ofType:@"csv"];
NSString *contents = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@",contents); NSArray *contentsArray = [contents componentsSeparatedByString:@"\r\n"];
NSString *docs = [NSHomeDirectory() stringByAppendingPathComponent:@"shortcuts.plist"];
NSLog(@"路径:%@", docs);
NSMutableArray *arr = [[NSMutableArray alloc] init];
NSInteger idx;
for (idx = ; idx < contentsArray.count; idx++) {
NSString* currentContent = [contentsArray objectAtIndex:idx];
NSArray *timeDataArr = [currentContent componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]];
NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
[dic setObject:[timeDataArr objectAtIndex:] forKey:@"postCode"];
[dic setObject:[timeDataArr objectAtIndex:] forKey:@"locationName"];
[dic setObject:[timeDataArr objectAtIndex:] forKey:@"phoneCode"];
[arr addObject:dic];
}
[arr writeToFile:docs atomically:YES];
}
iOS将excel转plist的更多相关文章
- ios开发之Info.plist文件相关配置
前言:在iOS开发中有些情况下需要对Info.plist文件进行配置,以下介绍几种相关配置.以后遇到需要配置的再更新... 开发环境:swift3.0.1,Xcode8.1 一,项目中需要使用第三方字 ...
- Delphi Berlin 10.1 for iOS 成生 info.plist 顺序改变了
在 Delphi Seattle 10 update 1 版本(含之前版本),只要 Project > Build 会立即生成 info.plist 如果需要修改 info.plist 可以利用 ...
- iOS项目开发实战——plist数组解析
plist数据是苹果公司创造的数据格式,基于XML,因为在iOS,Mac系统中操作plist很方便,所以我们经常会用到.在iOS项目中.系统会自己主动生成一个Info.plist文件,里面存放了iOS ...
- iOS通过设置info.plist参数使用iTunes导入导出Documents目录下的文件
参考网址: http://my.oschina.net/hmj/blog/112592 http://www.cnblogs.com/taintain1984/archive/2013/05/27/3 ...
- 关于iOS开发中info.plist文件的解读
我们建立一个工程后,会在Supporting files下面看到一个"工程名-Info.plist"的文件,这个是对工程做一些运行期配置的文件,很重要,不能删除. 下面就对其ke ...
- iOS开发之Info.plist文件
建立一个工程后,会在Supporting files文件夹下看到一个“工程名-Info.plist”的文件,该文件对工程做一些运行期的配置,非常重要,不能删除 在旧版本Xcode创建的工程中,这个配置 ...
- iOS开发中,info.plist配置用户隐私的保护
info.plist 配置[用户隐私的保护] >= iOS10 Privacy - Bluetooth Peripheral Usage Description --> App需要您的 ...
- Objc将数据写入iOS真机的plist文件中
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 如何写入模拟器的博文在 这里 但是这对真机不管用,因为在真机环 ...
- ios之如何读取plist
- (NSDictionary*)contactsInfoFromPlistNamed:(NSString*)plistName { NSString *path = [[NSBundle mainB ...
随机推荐
- [转]Unity手游之路<十二>手游资源热更新策略探讨
最近梳理了下游戏流程.恩,本来想写下,但是,还是看前辈的吧 版权声明: https://blog.csdn.net/janeky/article/details/17666409 上一次我们学习了如何 ...
- java转换日期格式为 RFC1123
import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util. ...
- LeetCode: First Missing Positive 解题报告
First Missing Positive Given an unsorted integer array, find the first missing positive integer. For ...
- Tomcat配置多个域名绑定到不同项目
<Host name="www.dn-serve.com" appBase="webapps" unpackWARs="true" a ...
- Halcon的数据类型
两大类: 1.图形参数Iconic (image, region, XLD) 2.与控制参数Control (string, integer, real, handle), 在Halcon算子的参数中 ...
- CFA一级知识点总结
更多来自: www.vipcoursea.com Ethics 部分 Objective of codes and standard:永远是为了maintain public trust in ...
- spring data jpa 查询自定义字段,转换为自定义实体
目标:查询数据库中的字段,然后转换成 JSON 格式的数据,返回前台. 环境:idea 2016.3.4, jdk 1.8, mysql 5.6, spring-boot 1.5.2 背景:首先建立 ...
- java-信息安全(十三)-数字签名,代码签名【Java证书体系实现】
概述 信息安全基本概念 前置 java-信息安全(十二)-数字签名[Java证书体系实现] 过程 通过工具JarSigner可以完成代码签名. 这里我们对tools.jar做代码签名,命令如下: 进 ...
- tomcat 下安装 MantisBT
环境 OS:win8.1 up1 64bit tomcat :9.0.0 64bit php: php-7.1.7-nts-Win32-VC14-x64.zip postgres: postgresq ...
- 使用 ssh -R 穿透局域网访问内部服务器主机,反向代理 无人值守化
一.搭建SSH方向代理 准备: 局域网主机(虚拟主机): 192.168.6.233 CentOS 6.7 阿里云服务器:120.25.68.60 CentOS 6.7 1. 阿里云服务器12 ...