Last active
January 21, 2016 05:08
-
-
Save karlbecker/3c9084dce58e80437697 to your computer and use it in GitHub Desktop.
NSURLComponents queryItems as an NSDictionary
This file contains hidden or 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
// | |
// NSURLComponents+QueryItemsDictionary.m | |
// browzine | |
// | |
// Created by Karl Becker on 1/20/16. | |
// Copyright © 2016 Third Iron. All rights reserved. | |
// | |
// Requires https://github.com/grav/nsarray-functional | |
#import <Foundation/Foundation.h> | |
#import "NSArray+Functional.h" | |
@interface NSURLComponents (QueryItemsDictionary) | |
- (NSDictionary *)queryItemsDictionary; | |
@end | |
@implementation NSURLComponents (QueryItemsDictionary) | |
- (NSDictionary *)queryItemsDictionary { | |
NSMutableDictionary *queryItems = [NSMutableDictionary dictionary]; | |
[self.queryItems applyBlock:^(NSURLQueryItem *queryItem) { | |
[queryItems setObject:queryItem.value forKey:queryItem.name]; | |
}]; | |
return queryItems; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment