有没有办法从iOS中的plist加载const unsigned char?

时间:2015-11-03 19:15:11

标签: ios objective-c plist

我有一些我的应用授权数据,如{0x7c,0x1e,...},我需要在Objective-C文件中获取它,如:

const unsigned char ApplicationKey[] = {0x7c, 0x1e, ...};

有没有办法从plist-file获取这个const?

我需要这个,因为根据这个答案this answer这是NuanceHeader.m中的事情我想把我的AppKey存储在plist中,而不是代码。

1 个答案:

答案 0 :(得分:0)

基本上,plist可以包含NSNumber个实例形式的数值。您可以非常轻松地创建unsigned char

NSString* pathToPlist = // Determine path to plist
NSArray* plist = [NSArray arrayWithContentsOfFile:pathToPlist];
unsigned char applicationKey[plist.count];
[plist enumerateObjectsUsingBlock:^(NSNumber* number, NSUInteger index, BOOL* stop) {
    applicationKey[index] = [number unsignedCharValue];
}];