[TIMOB-23508] iOS: Use native NSData base64 encode API to replace our current methods
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | None |
| Status | Closed |
| Resolution | Duplicate |
| Resolution Date | 2016-07-31T15:15:25.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | n/a |
| Reporter | Angel Petkov |
| Assignee | Angel Petkov |
| Created | 2016-06-13T22:43:34.000+0000 |
| Updated | 2016-07-31T15:15:31.000+0000 |
Description
Replacing our base64encode/decode methods with a more versatile methods, using [base64EncodedDataWithOptions](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/#//apple_ref/occ/instm/NSData/base64EncodedDataWithOptions:).
Demo Code:
var win = Ti.UI.createWindow({backgroundColor:'white'});
var longString = 'ABCDEFGHIJ1234567890ABCDEFGHIJ12|psndemo2|abcd:12345678901234567890';
var tiBase64ShortResult = Ti.Utils.base64encode(longString,Ti.Utils.ENCODE_TYPE_CR);
var tiBase64ShortResult = String(tiBase64ShortResult);
var decodededString = Ti.Utils.base64decode(tiBase64ShortResult);
var alertDialog = Titanium.UI.createAlertDialog(
{
title: 'Result',
message: 'short: ' + tiBase64ShortResult, buttonNames: ['OK','Cancel']
});
alertDialog.show();
if (decodededString == longString) {
Ti.API.info("Match!");
}
win.open();
*Expected Result*
* The encoded string inside the alert should have Carriage Return
* "Match!" should be logged to confirm the decoded string matches the original
PR:https://github.com/appcelerator/titanium_mobile/pull/8058