On entering a new data into my core data for my given entity, how do I check if the entry for a particular attribute is null?
I have three attribute
name, mail and mailedCustomer.
I add data as follows:
SalesPerson *data = (SalesPerson *)[NSEntityDescription insertNewObjectForEntityForName:@"SalesPerson" inManagedObjectContext:self.managedObjectContext];
[data setName:name];
[data setEmail:userEmail];
NSLog(@" mailed personel%@",data.mailedCustomer);
if([data.mailedCustomer != nil){
NSLog(@"inside condition");
[data setMailedCustomer:@"//"];
}
This doesn’t work for me. Im trying to append some strings. So when I enter for the first time I need that attribute to be @”//” then append on further calls.
NSLog(@" mailed personnel %@",data.mailedCustomer);
The above NSLog gives me:
mailed personnel (null)
If I get what you want, your if statement is incorrect. You’re now checking if it’s NOT nil (meaning it has some value), and then you’re resetting it to //. If you want it to be // and then append values, you have to check if it IS nil and then set it to //: