SuperMap iMobile for iOS 入门&数据部署
来源:互联网 发布:2014双11淘宝销售额 编辑:程序博客网 时间:2024/05/18 08:45
数据是GIS 应用的基础,与所有GIS 应用一样,使用SuperMap iMobile for iOS 开发的应用也离不开数
据。而且iOS 应用是在移动终端上运行,数据需要通过数据线连接,通过iTunes 拷贝,操作比较繁琐。
其实可以将数据打包添加到工程中,在程序启动时将其一同部署。
本文在iMobile for iOS 的产品入门工程的基础上,介绍在代码工程中添加数据并部署到移动终端的方法
——借助bundle,将数据打成bundle 包,添加到工程。若应用中不编辑数据,则代码中直接使用bundle
中的数据即可;若要编辑数据,则在应用启动时将bundle 中的数据拷贝至应用的Document 目录。通过代
码部署数据的方式,使得应用部署的同时数据也一同部署,不需要再单独拷贝。
新建工程
按SuperMap iMobile for iOS 帮助文档中开发入门的操作步骤,以二维移动GIS 应用程序开发为例,基于模
板的工程完成前两步,如图 1,完成新建工程及代码编写。完成后工程目录如图 2 所示。
准备数据
入门工程用到的示范数据位于【SuperMap iMobile 7C for iOS 解压目录】\SampleData\World 目录,入门示范
中,传入数据到真机需要借助iTunes,本文将跳过此步骤,利用捆绑包将数据添加到工程中,并在程序启
动时部署到移动设备上。
首先,在Mac 系统中,新建一个文件夹Data,将SampleData\World 目录下的World.smuw、World.udb 和
World.udb 文件拷贝至Data 目录中,许可文件也可以拷贝至Data 目录,如图 3 所示。
重命名Data 目录,添加后缀.bundle,会弹出消息框,确认添加bundle 后缀,单击“添加”,添加后Data.bundle
就显示为了一个单文件,如图 6 所示。
按住Data.bundle 拖拽,将其添加到工程中,见图 7。在Finder 中看,Data.bundle 是一个单独的文件,在
Xcode 中,则可以展开它看到其内容,见图 8。
拷贝数据
代码中将Data.bundle 中的文件拷贝至应用的Document 目录:在ViewController.m 中增加copyDataFile 方
法,在viewDidLoad 方法中增加调用。
-(void)viewDidLoad{ [super viewDidLoad]; [self copyDataFile:@"World.smwu"]; [self copyDataFile:@"World.udb"]; [self copyDataFile:@"World.udd"]; [self copyDataFile:@"SuperMap iMobile Trial.slm"]; [self openData];}-(void)copyDataFile:(NSString*)fileName{ NSString * bundlePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:@"Data.bundle"]; NSString *srcPath = [bundlePath stringByAppendingFormat:@" /%@",fileName]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docDirectory = [paths objectAtIndex:0]; NSString *dstPath = [docDirectory stringByAppendingPathComponent:fileName]; NSFileManager *fileManager = [NSFileManager defaultManager]; BOOL bExist = [fileManager fileExistsAtPath:dstPath]; if (!bExist) { [fileManager copyItemAtPath:srcPathtoPath:dstPath error:nil]; }}……
- SuperMap iMobile for iOS 入门&数据部署
- SuperMap iMobile for IOS-数据操作
- SuperMap iMobile for iOS 三维入门开发教程(一)
- SuperMap iMobile for iOS地图开发入门—XIB模式
- SuperMap iMobile for iOS 之行业导航
- 浅析SuperMap iMobile 8C for iOS打包静态库
- SuperMap iMobile for iOS 8C三维应用实例
- SuperMap iMobile 8C(2017) for Android 离线数据使用说明
- SuperMap iMobile for Android培训资料
- supermap imobile for android iServer服务查询
- SuperMap iMobile for Android定位实现
- SuperMap iMobile for Android 三维开发指南
- SuperMap iMobile for Android 三维开发指南
- SuperMap iMobile for Android许可配置介绍
- superMap iMobile for iOS 使用代码在地图上画一条线
- SuperMap iMobile for Android 点线面数据采集之添加编辑属性值
- supermap imobile for android 在代码中画一条直线
- SuperMap iMobile for Android常见问题解答集锦(十三)
- Linux配置java环境变量(详细)
- Combination Sum II
- AdaBoost训练
- 转载:[译] 内容加速黑科技趣谈
- linux内核SPI总线驱动分析
- SuperMap iMobile for iOS 入门&数据部署
- 轻量级操作系统FreeRTOS的内存管理机制(三)
- 二维地图性能排查
- [李景山php]关于数据结构小结
- sql的limit
- RCU(Read-Copy Update)synchronize原理分析
- matlab 批量读取文件夹中的图片、处理后、保存于另一文件夹
- TensorsFlow学习笔记5----TensorFlow Mechanics 101基本运作方式
- windows10 1703显示 *某些设置隐藏或者由你的组织来管理解决办法