NSError no visible interface iOS 8.1

396 views Asked by At

This piece of code was working on iOS 8. However, now when I build in release mode I get a

No Visible @interface for 'NSError' declares the selector 'code'.

Code is found on NSError. I can click into it and see that, however, I don't understand why it just stopped working with xcode 6.1 and iOS 8.1

I tried building on 5.1.1 and it built fine in release mode.

+(BOOL) isResponseError:(NSURLResponse *)response responseString:(NSString *)responseString error:(NSError *__autoreleasing *)error {
    NSInteger statusCode = 0;

    if (*error) {
        statusCode = [*error code];
    }

    if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
        statusCode = [(NSHTTPURLResponse *)response statusCode];
    }

    if (statusCode >= 400 || statusCode <= kCFURLErrorUnknown) {
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        [dic setValue:[NSHTTPURLResponse localizedStringForStatusCode:statusCode] forKey:NSLocalizedDescriptionKey];


        return true;
    } else {
        id ret = [Serialization deserializeJSON:responseString];

        if ([ret superclass] == [NSMutableDictionary class] || [ret class] == [NSDictionary class]) {
            if ([ret objectForKey:@"error"]) {
                NSMutableDictionary *dic = [NSMutableDictionary dictionary];
                [dic setValue:[ret objectForKey:@"error"] forKey:NSLocalizedDescriptionKey];
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
}
1

There are 1 answers

0
zaph On BEST ANSWER

You are passing in an NSError instance so you do not need __autoreleasing or pointer to pointer:

+(BOOL) isResponseError:(NSURLResponse *)response responseString:(NSString *)responseString error:(NSError *)error {
    NSInteger statusCode = 0;

    if (error) {
        statusCode = [error code];
    }

If there was no error prior to 8.1 and is not that is because the compiler error checking was improved.