This repository has been archived by the owner on Aug 16, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
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
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
19 changes: 19 additions & 0 deletions
19
CMDQueryStringSerialization/NSURL+CMDQueryStringSerialization.h
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NSURL+CMDQueryStringSerialization.h | ||
// CMDQueryStringSerialization | ||
// | ||
// Created by Caleb Davenport on 5/28/15. | ||
// Copyright (c) 2015 Caleb Davenport. All rights reserved. | ||
// | ||
|
||
@import Foundation; | ||
|
||
@interface NSURL (CMDQueryStringSerialization) | ||
|
||
@property (nonatomic, readonly) NSDictionary *cmd_queryDictionary; | ||
|
||
- (NSURL *)cmd_URLWithQueryDictionary:(NSDictionary *)dictionary; | ||
|
||
- (NSURL *)cmd_URLByAddingQueryDictionary:(NSDictionary *)dictionary; | ||
|
||
@end |
33 changes: 33 additions & 0 deletions
33
CMDQueryStringSerialization/NSURL+CMDQueryStringSerialization.m
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// NSURL+CMDQueryStringSerialization.m | ||
// CMDQueryStringSerialization | ||
// | ||
// Created by Caleb Davenport on 5/28/15. | ||
// Copyright (c) 2015 Caleb Davenport. All rights reserved. | ||
// | ||
|
||
#import "NSURL+CMDQueryStringSerialization.h" | ||
#import "CMDQueryStringSerialization.h" | ||
|
||
@implementation NSURL (CMDQueryStringSerialization) | ||
|
||
- (NSURL *)cmd_URLWithQueryDictionary:(NSDictionary *)dictionary { | ||
NSURLComponents *components = [NSURLComponents componentsWithURL:self resolvingAgainstBaseURL:YES]; | ||
components.query = [CMDQueryStringSerialization queryStringWithDictionary:dictionary]; | ||
return components.URL; | ||
} | ||
|
||
- (NSURL *)cmd_URLByAddingQueryDictionary:(NSDictionary *)dictionary { | ||
NSURLComponents *components = [NSURLComponents componentsWithURL:self resolvingAgainstBaseURL:YES]; | ||
NSMutableDictionary *mutableParameters = [[NSMutableDictionary alloc] init]; | ||
[mutableParameters addEntriesFromDictionary:[CMDQueryStringSerialization dictionaryWithQueryString:components.query]]; | ||
[mutableParameters addEntriesFromDictionary:dictionary]; | ||
components.query = [CMDQueryStringSerialization queryStringWithDictionary:mutableParameters]; | ||
return components.URL; | ||
} | ||
|
||
- (NSDictionary *)cmd_queryDictionary { | ||
return [CMDQueryStringSerialization dictionaryWithQueryString:self.query]; | ||
} | ||
|
||
@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