Afnetworking: Crash at NSParameterAssert(URLString) AFURLRequestSerialization.m line 367

Created on 20 Oct 2015  ·  5Comments  ·  Source: AFNetworking/AFNetworking

Hi,

i have a weird bug.

at

- (AFHTTPRequestOperation *)HTTPRequestOperationWithHTTPMethod:(NSString *)method
                                                     URLString:(NSString *)URLString
                                                    parameters:(id)parameters
                                                       success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                                                       failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure

the URLString is already set but in the next method which is called here

[self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];

the URLString is nil. But i don't know why?
Any help or idea for this issue?

Thanks

Most helpful comment

I have also encountered this error, however, I found my URL add a space

All 5 comments

Can you post example code demonstrating the problem? Also, what version of AFNetworking are you using?

URLString is converted under the hood using:

[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString]

If that method returns nil, you would end up with a nil string. Confirm your string is a valid URL String.

:beers:

I have also encountered this error, however, I found my URL add a space

@kcharwood you're totally right. thanks.

I have also encountered this error, however, I found my URL add a space

Your answer solves my problem!
"https://lconfig.xxx" <-> " https://lconfig.xxx"

Was this page helpful?
0 / 5 - 0 ratings