Last active
December 8, 2015 14:32
-
-
Save AlexChesters/c554533bf8b85891e119 to your computer and use it in GitHub Desktop.
URLBuilder class written in Objective-C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// URLBuilder.h | |
// lyrical | |
// | |
// Created by Alex Chesters on 13/11/2015. | |
// Copyright © 2015 Alex Chesters. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface URLBuilder : NSObject | |
- (NSURL *)withScheme:(NSString *)scheme host:(NSString *)host path:(NSString *)path queryItems:(NSArray *)queryItems; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// URLBuilder.m | |
// lyrical | |
// | |
// Created by Alex Chesters on 13/11/2015. | |
// Copyright © 2015 Alex Chesters. All rights reserved. | |
// | |
#import "URLBuilder.h" | |
@implementation URLBuilder | |
- (NSURL *)withScheme:(NSString *)scheme host:(NSString *)host path:(NSString *)path queryItems:(NSArray *)queryItems { | |
NSURLComponents *components = [[NSURLComponents alloc] init]; | |
[components setScheme:scheme]; | |
[components setHost:host]; | |
[components setPath:path]; | |
if (queryItems && queryItems.count > 0) { | |
[components setQueryItems:queryItems]; | |
} | |
return components.URL; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment