If you don't use Core Data, you could do:
NSPredicate *predicateName = [NSPredicate predicateWithFormat:@"name.length > 0"];
If the string is empty, this will fail (because 0 == 0
). Similarly, if name
is nil
, it will also fail, because [nil length] == 0
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…