2014-07-01 313 views
5

我從GitHub.I下載了Base64庫,在我的項目中使用它來解碼來自Web服務器的圖像。我做了這個項目iOS7.0警告我使用Base64得到的是:提前Base64Encoding已棄用:iOS 7.0中已棄用

'base64Encoding' is deprecated : first deprecated in iOS7.0.

感謝。

回答

3

從iOS的7 SDK開始,NSData class現在有幫助編碼/解碼基地64個數據和字符串對象有以下方法:

- (instancetype)initWithBase64EncodedData:(NSData *)base64Data 
            options:(NSDataBase64DecodingOptions)options 

- (instancetype)initWithBase64EncodedString:(NSString *)base64String 
            options:(NSDataBase64DecodingOptions)options 

一旦你得到了你的NSData實例初始化一個UIImage對象有:+(的UIImage *)imageWithData:(NSData的*)數據

類型的編碼:

- NSDataBase64Encoding64CharacterLineLength  
    NSDataBase64Encoding76CharacterLineLength  
    NSDataBase64EncodingEndLineWithCarriageReturn  
    NSDataBase64EncodingEndLineWithLineFeed 

類型解碼的:

- NSDataBase64DecodingIgnoreUnknownCharacters 
+0

請告訴我有變化RFC規格那裏看到NSDataBase64Encoding64CharacterLineLength和NSDataBase64Encoding76CharacterLineLength –

+1

之間的差[維基鏈接](http://en.wikipedia.org/wiki/Base64#Implementations_and_history)。 NSData必須支持所有長度,除了最大長度和何時插入換行符之外,沒有太大差別 –