diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index a193a9d..aee0738 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -221,6 +221,12 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { return [[self alloc] initWithBaseURL:url]; } +- (instancetype)init { + @throw [NSException exceptionWithName:NSInternalInconsistencyException + reason:[NSString stringWithFormat:@"%@ Failed to call designated initializer. Invoke `initWithBaseURL:` instead.", NSStringFromClass([self class])] + userInfo:nil]; +} + - (id)initWithBaseURL:(NSURL *)url { NSParameterAssert(url); diff --git a/Tests/AFHTTPClientTests.m b/Tests/AFHTTPClientTests.m index 0ba0032..4fcc287 100644 --- a/Tests/AFHTTPClientTests.m +++ b/Tests/AFHTTPClientTests.m @@ -35,6 +35,10 @@ #pragma mark - +- (void)testInitRaisesException { + expect(^{ (void)[[AFHTTPClient alloc] init]; }).to.raiseAny(); +} + - (void)testDefaultHeaders { [self.client setDefaultHeader:@"x-some-key" value:@"SomeValue"]; expect([self.client defaultValueForHeader:@"x-some-key"]).to.equal(@"SomeValue");