iphoneiosxcodegeneral-network-error

How to change the error "host not found" to my customised message error?


The problem is I have these messages :

Especially the second message it shows for a second and then everything become working

So what I want is to know how to find these msgs and how to handle them and put my message instead of them or just make another action instead of showing them like the facebook app , when the connection down it shows a red alert with label "network error"

How can I do this?


Solution

  • finally i found the solution and its like this

    -(void)handleError:(NSError*)error{
    SEL onerror = @selector(onerror:);
    if(self.action != nil) { onerror = self.action; }
    if([self.handler respondsToSelector: onerror]) {
        if (error.code == -1003 || error.code == -1001 || error.code == -1004) { //check all kind of errors
            [self send];
        }else{
        [self.handler performSelector: onerror withObject: error];
        }
    } else {
        if(self.defaultHandler != nil && [self.defaultHandler respondsToSelector:onerror]) {
            [self.defaultHandler performSelector:onerror withObject: error];
        }
    }
    if(self.logging) {
        NSLog(@"Error: %@", error.localizedDescription);
    }
    

    }