Reputation: 5107
I am trying to store a UITextView content to a core data object if a condition is true:
...
//implementation
NSString *textActualDescription;
...
//save action
...
//
NSString *descriptionText = ToDoDescriptionTextField.text;//assign text from UITextView to descriptionText.
[textActualDescription isEqualToString:@"Enter ToDo Description here or leave this message to enter a blank description."];//assign string to textActualDescription.
if ([descriptionText isEqualToString:textActualDescription]){
[favoriteThing setValue:descriptionText forKey:@"thingDescription"];//if equal.
}
else {
[favoriteThing setValue:@"No description" forKey:@"thingDescription"];//if not equal.
}
...
//saving core data
The app stores perfectly all the rest of attributes, but in this case, the comparison is not recognised in any case, and always takes the 'else' option. As default the UITextView ToDoDescriptionTextField text is the same as the string assigned to 'textActualDescription'. What is wrong there?
Upvotes: 0
Views: 229
Reputation: 5824
The textActualDescription
is not being assigned any value. Instead of:
[textActualDescription isEqualToString:@"Enter ToDo Description here or leave this message to enter a blank description."];//assign string to textActualDescription.
use:
textActualDescription = @"Enter ToDo Description here or leave this message to enter a blank description.";//assign string to textActualDescription.
Upvotes: 2