简体   繁体   English

无法将应用捆绑包转换为NSData

[英]Can't convert app bundle to NSData

I'm trying to convert my bundle to NSData so that I can hash the data and have a server verify the hash before allowing downloads. 我正在尝试将捆绑软件转换为NSData,以便可以对数据进行哈希处理,并让服务器在允许下载之前验证哈希值。 The only problem is that when I try to convert the bundle to NSData, I get Error: The operation couldn't be completed. (Cocoa error 257.) 唯一的问题是,当我尝试将捆绑软件转换为NSData时,出现Error: The operation couldn't be completed. (Cocoa error 257.) Error: The operation couldn't be completed. (Cocoa error 257.) I looked up error 257 and it means that the bundle couldn't be read due to a permissions problem. Error: The operation couldn't be completed. (Cocoa error 257.)我查找了错误257,这意味着由于权限问题而无法读取该捆绑软件。 What am I doing incorrectly? 我做错了什么? Thanks for your help. 谢谢你的帮助。

NSString *bundlePath = [[NSBundle mainBundle] resourcePath];  
NSLog(@"%@", bundlePath);
NSError *error;
NSData *bData = [NSData dataWithContentsOfFile:bundlePath options:nil error:&error];
NSLog(@"Error: %@", [error localizedDescription]);

If piracy protection is your ultimate goal, refer to this for a little insight and code. 如果盗版保护是您的最终目标,请参考此内容以获取一些见识和代码。

http://thwart-ipa-cracks.blogspot.com/2008/11/detection.html?m=1 http://thwart-ipa-cracks.blogspot.com/2008/11/detection.html?m=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM