我制作了 Sender 类和 sender 对象:
Sender *sender = [[Sender alloc] init];
然后,我写了测试:
// should success
[sender upload:[UIImage imageNamed:@"test2.jpg"] withName:@"test2.jpg"];
// should fail
[sender upload:nil withName:@"test2.jpg"];
然后,我写了 nil 检查代码:
- (void)upload:(UIImage *)image withName:(NSString *)name
{
if ([image isEqual:nil]) {
...
}
...
}
但 nil 检查被忽略。如何检查图像参数是否为零?谢谢你的好意。