AFNetworking - Invalid parameter not satisfying: url

As Leon says in his comment, commenting out NSParameterAssert is not an ideal solution. An assertion has been put there for a reason by the author of AFNetworking. The code not passing the assertion is likely to be caused by an invalid URL.

Remember that the NSURL factory methods (that is, + URLWithString: and its siblings) will return nil when they're passed an invalid URL string. In this context, an invalid string is a string containing an invalid URL.

What you should do instead of commenting our the assertion, is making sure that you are not passing any invalid URL's to your AFHTTPClient instance. This Stackoverflow answers gives an example of how you could validate a URL. Here's a sample from the answer:

- (BOOL)validateUrl:(NSString *)candidate {
    NSString *urlRegEx = @"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+";
    NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx]; 
    return [urlTest evaluateWithObject:candidate];
}

Alternatively, you could add percentage escapes using NSString's stringByAddingPercentEscapesUsingEncoding method. Like this:

NSString *encoded = [notEncoded stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

I just had this error, the cause was a space at the start of the url:

 http://host.com/etc
^