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());
Addressed in PR: https://github.com/appcelerator/titanium_mobile/pull/2283
APIDocs fixed in https://github.com/appcelerator/titanium_mobile/pull/2269
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
Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4731