Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9223] iOS: UI.Clipboard hasText returns Number rather than Boolean

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-06-02T22:27:38.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sRelease 2.1.0, Sprint 2012-11 API
ComponentsiOS
Labelsmodule_clipboard, parity, qe-testadded
ReporterPaul Dowsett
AssigneeArthur Evans
Created2012-05-24T08:00:56.000+0000
Updated2013-11-06T19:04:28.000+0000

Description

Problem

The hasText method of [Titanium.UI.Clipboard](http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.UI.Clipboard) returns a Number 0 or 1 rather than true or false respectively. See the test case below, and the source at [TiUIClipboardProxy.m](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiUIClipboardProxy.m). Note that Android returns Boolean as expected.

Test case

Titanium.UI.setBackgroundColor('#000');

Ti.API.log('Deleting all text in Clipboard');
Ti.UI.Clipboard.clearText();
Ti.API.log('Clipboard.getText() empty: ' + Ti.UI.Clipboard.getText()); // returns undefined when empty
Ti.API.log('Set text Clipboard to hello');
Ti.UI.Clipboard.setText('hello');
Ti.API.log('Clipboard.hasText(), should be true: ' + Ti.UI.Clipboard.hasText()); // hasText() returns 0 or 1 instead of boolean
Ti.API.log('Clipboard.getText(), should be hello: ' + Ti.UI.Clipboard.getText());

Comments

  1. Arthur Evans 2012-05-27

    Addressed in PR: https://github.com/appcelerator/titanium_mobile/pull/2283
  2. Paul Dowsett 2012-05-29

    APIDocs fixed in https://github.com/appcelerator/titanium_mobile/pull/2269
  3. Satyam Sekhri 2012-06-04

    The clipboard methods hasText returns boolean value True/False. Verified on: Titanium Studio: 2.1.0.201206010843 Titanium SDK: 2.1.0.v20120604151821 iOS Simulator 5.0
  4. Shameer Jan 2013-11-06

    Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4731

JSON Source