如果条件为真,我试图将UITextView内容存储到核心数据对象:
...
//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
应用程序完美地存储了所有其他属性,但在这种情况下,无论如何都无法识别比较,并始终采用“else”选项。默认情况下,UITextView ToDoDescriptionTextField文本与分配给“textActualDescription”的字符串相同。 有什么问题?
答案 0 :(得分:2)
textActualDescription
未分配任何值。而不是:
[textActualDescription isEqualToString:@"Enter ToDo Description here or leave this message to enter a blank description."];//assign string to textActualDescription.
使用:
textActualDescription = @"Enter ToDo Description here or leave this message to enter a blank description.";//assign string to textActualDescription.