我用[[NSDataalloc]initWithBase64EncodedString:contentoptions:0];加载通过网络传递的二进制数据,作为JSON对象的键。有时它有效,但在其他情况下它失败了,比如thisstring.这是NSData本身在另一端创建的字符串:[database64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];有没有我必须通过的选项,为什么它返回零?String的长度是4的倍数并且没有奇怪的字符,所以我不明白为什么会失败? 最佳答案
我已经从GitHub下载了Base64库。我在我的项目中使用它来解码来自网络服务器的图像。我为iOS7.0制作了这个项目使用base64得到的警告是:'base64Encoding'isdeprecated:firstdeprecatediniOS7.0.提前致谢。 最佳答案 从iOS7SDK开始,NSDataclass现在有一些方法可以帮助编码/解码base64数据和字符串对象,方法如下:-(instancetype)initWithBase64EncodedData:(NSData*)base64Dataoptions:(NSD
我有一个字典数组,类似于以下内容:({Black="?";Date="????.??.??";Result="*";SourceDate="2007.10.24";White="Matingpattern#1";},{Black="?";Date="????.??.??";Result="*";SourceDate="2008.10.24";White="AboutthisPublication";})Iwanttooffertheusertheabilitytosearchfortexteitherwithinjustthe"White"and"Black"fields,orwith
昨天我为此写了一个工作代码,但我删除了它,当写一个新的代码时,有些东西真的很奇怪:我用这种方式编码图片:letpictureData=UIImagePNGRepresentation(picture!)letpictureToString64=pictureData?.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)(我之前有JPEGRepresentation,但它不起作用,所以我尝试使用JPEG)我通过获取pic64以这种方式解码,我相信它具有正确的值。