iOS 百度SDK离线地图下载

在进行集成百度iOS sdk的时候,进行离线地图下载的时候,会出现错误:

availableDiskSpace方法找不到,但是如何解决呢,需要对UIDevice进行扩展:
具体的代码片段:
“UIDevice+Manager.h”

1
2
3
4
5
6
7
8
9
10
11
12
13
//
// UIDevice+Manager.h
//
//

#import <UIKit/UIKit.h>
#import <mach/mach.h>

@interface UIDevice (DiskManager)

- (BOOL)availableDiskSpace;

@end

“UIDevice+Manager.m”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// UIDevice+DiskManager.m

#import "UIDevice+Manager.h"

@implementation UIDevice (DiskManager)

- (BOOL)availableDiskSpace{
if ([self availableMemory] > 0) {
return TRUE;
}
return FALSE;
}


- (double)availableMemory{
vm_statistics_data_t vmStats;
mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
kern_return_t kernReturn = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmStats, &infoCount);
if (kernReturn != KERN_SUCCESS ) {
return NSNotFound;
}
double availableMem = ((vm_page_size* vmStats.free_count) / 1024.0)/1024.0;
NSLog(@"可使用内存大小为: %f",availableMem);
return availableMem;
}



@end

坚持原创技术分享,您的支持将鼓励我继续创作!
关注微信公众号 haibintalk,最新文章主动推送
关注微信公众号: haibintalk