把这个放到*perror = error线上。即使我把它包装成if (error)

- (BOOL)validate:(NSError **)perror password:(BOOL)password {
    BOOL ret = YES;

    NSMutableString * errorMessage = [@"" mutableCopy];

    ...other validation code

    NSError * error = [NSError errorWithDomain:@"Profile" code:100 userInfo:dictionary];

    if (error) {
       *perror = error;
    }

    return  ret;
}

最佳答案

有可能perror就是nil。谨防:

if (error && perror) {
    *perror = error;
}

10-08 04:10