Permalink
Browse files

[UI] Using new TTisStringWithAnyText for deprecated isEmptyOrWhiteSpace.

  • Loading branch information...
1 parent aeaa06a commit cac29ca0faecb630182ab9fe55f2cc53b5d8fd80 @jwang jwang committed Feb 16, 2011
@@ -43,6 +43,7 @@
#import "Three20Core/TTGlobalCoreLocale.h"
#import "Three20Core/TTGlobalCoreRects.h"
#import "Three20Core/NSStringAdditions.h"
+#import "Three20Core/TTGlobalCore.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -189,7 +190,7 @@ - (BOOL)hasEnteredText {
} else if ([field isKindOfClass:[TTMessageTextField class]]) {
UITextField* textField = [_fieldViews objectAtIndex:i];
- if (!textField.text.isEmptyOrWhitespace) {
+ if (!TTIsStringWithAnyText(textField.text)) {
@jverkoey
jverkoey Feb 17, 2011 Contributor

I read the old logic as "if the text field's text is not empty or whitespace", so it won't be enough to just check whether it's a non-empty string here.

Something closer to:

if (TTIsStringWithAnyText(textField.text)
    && !textField.text.isWhitespaceAndNewlines) {

will more closely map to the original logic, while being more verbose in our intentions.

return YES;
}
}
@@ -217,7 +218,7 @@ - (BOOL)hasRequiredText {
} else if ([field isKindOfClass:[TTMessageTextField class]]) {
UITextField* textField = [_fieldViews objectAtIndex:i];
- if (textField.text.isEmptyOrWhitespace) {
+ if (TTIsStringWithAnyText(textField.text)) {
@jverkoey
jverkoey Feb 17, 2011 Contributor

Same sort of problem here, though a bit tricker.

This is testing if the text field's text is empty or only contains whitespace.

So:

if (0 == textField.text.length || textField.text.isWhitespaceAndNewlines) {
return NO;
}
}
@@ -658,10 +659,10 @@ - (BOOL)fieldHasValueAtIndex:(NSUInteger)fieldIndex {
TTMessageField* field = [_fields objectAtIndex:fieldIndex];
if ([field isKindOfClass:[TTMessageRecipientField class]]) {
TTPickerTextField* pickerTextField = [_fieldViews objectAtIndex:fieldIndex];
- return !pickerTextField.text.isEmptyOrWhitespace || pickerTextField.cellViews.count > 0;
+ return !TTIsStringWithAnyText(pickerTextField.text) || pickerTextField.cellViews.count > 0;
} else {
UITextField* textField = [_fieldViews objectAtIndex:fieldIndex];
- return !textField.text.isEmptyOrWhitespace;
+ return !TTIsStringWithAnyText(textField.text);
}
}
}
@@ -38,7 +38,7 @@
#import "Three20Core/TTGlobalCoreLocale.h"
#import "Three20Core/TTCorePreprocessorMacros.h"
#import "Three20Core/NSStringAdditions.h"
-
+#import "Three20Core/TTGlobalCore.h"
static const CGFloat kMarginX = 5;
static const CGFloat kMarginY = 6;
@@ -506,7 +506,7 @@ - (void)post {
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)cancel {
- if (!_textView.text.isEmptyOrWhitespace
+ if (!TTIsStringWithAnyText(_textView.text)
&& !(_defaultText && [_defaultText isEqualToString:_textView.text])) {
UIAlertView* cancelAlertView = [[[UIAlertView alloc] initWithTitle:
TTLocalizedString(@"Cancel", @"")
@@ -39,6 +39,7 @@
#import "Three20Core/TTGlobalCoreLocale.h"
#import "Three20Core/TTCorePreprocessorMacros.h"
#import "Three20Core/NSStringAdditions.h"
+#import "Three20Core/TTGlobalCore.h"
static CGFloat kMargin = 1;
static CGFloat kPadding = 5;
@@ -410,7 +411,7 @@ - (void)post {
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)cancel {
- if (!_textEditor.text.isEmptyOrWhitespace
+ if (!TTIsStringWithAnyText(_textEditor.text)
&& !(_defaultText && [_defaultText isEqualToString:_textEditor.text])) {
UIAlertView* cancelAlertView = [[[UIAlertView alloc] initWithTitle:
TTLocalizedString(@"Cancel", @"")

2 comments on commit cac29ca

@jverkoey
Contributor

In practice:

if (!textField.text.isEmptyOrWhitespace) {

becomes

if (TTIsStringWithAnyText(textField.text)
    && !textField.text.isWhitespaceAndNewlines) {

while

textField.text.isEmptyOrWhitespace

becomes

if (0 == textField.text.length || textField.text.isWhitespaceAndNewlines) {
@jwang
Contributor
jwang commented on cac29ca Feb 18, 2011

Also, meaning:
return !textField.text.isEmptyOrWhitespace;
becomes
return (TTIsStringWithAnyText(textField.text) && !textField.text.isWhitespaceAndNewlines);

Please sign in to comment.