Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23508] iOS: Use native NSData base64 encode API to replace our current methods

GitHub Issuen/a
TypeImprovement
PriorityNone
StatusClosed
ResolutionDuplicate
Resolution Date2016-07-31T15:15:25.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterAngel Petkov
AssigneeAngel Petkov
Created2016-06-13T22:43:34.000+0000
Updated2016-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

Comments

  1. Angel Petkov 2016-06-13

    PR:https://github.com/appcelerator/titanium_mobile/pull/8058
  2. Hans Knöchel 2016-07-31

JSON Source