GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - soberman/URLQueryBuilder: Handy NSURL category, that make URL creation easy and fast.

BranchesTags
Open more actions menu

Latest commit

 

History

6 Commits
6 Commits

Folders and files

NameName
Last commit message
Last commit date
LICENSE
LICENSE
 
 
NSURL+URLQueryBuilder.h
NSURL+URLQueryBuilder.h
 
 
NSURL+URLQueryBuilder.m
NSURL+URLQueryBuilder.m
 
 
README.md
README.md
 
 

Repository files navigation

NSURL+URLQueryBuilder

Fully Swift compatible handy category, that helps building GET queries with ease. All you need to do is to provide base URL and a dictionary of query items and get your ready-to-use NSURL as a return value.

NSString *baseURL = @"https://google.com/search";
NSDictionary *items = @{
    @"q"  : @"arsenkin.com",
    @"hl" : @"en_US",
    @"lr" : @"lang_en"
};

NSURL *URL = [NSURL ars_queryWithString:baseURL queryElements:items];  
// https://google.com/search?q=arsenkin.com&hl=en_US&lr=lang_en

Additional methods

URLQueryBuilder offers some more useful methods to create a ready URL for request.

Basic query creating

There are two ways, in which you can provide base URL: via NSString object and via NSURL object. Here are the most basic methods for that:

+ (NSURL *)ars_queryWithString:(NSString *)URL queryElements:(NSDictionary<NSString *,NSString *> *)queryElements;

+ (NSURL *)ars_queryWithURL:(NSURL *)URL queryElements:(NSDictionary<NSString *,NSString *> *)queryElements;
Query creation with resolving against base URL

There are also ways to build your NSURL while resolving the URL agains base URL:

+ (NSURL *)ars_queryWithString:(NSString *)URL queryElements:(NSDictionary<NSString *, NSString *> *)queryElements resolveAgainstBaseURL:(BOOL)resolve;

+ (NSURL *)ars_queryWithURL:(NSURL *)URL queryElements:(NSDictionary<NSString *, NSString *> *)queryElements resolveAgainstBaseURL:(BOOL)resolve;
Query with pointer to NSURLComponents

There is also a way to create your desired NSURL object as well as receiving the resulting NSURLComponents object, that was used to create the resulting URL, that you might want for further use.

+ (NSURL *)ars_queryWithString:(NSString *)URL queryElements:(NSDictionary<NSString *, NSString *> *)queryElements URLComponent:(NSURLComponents * _Nullable * _Nullable)URLComponent;

+ (NSURL *)ars_queryWithURL:(NSURL *)URL queryElements:(NSDictionary<NSString *, NSString *> *)queryElements URLComponent:(NSURLComponents * _Nullable * _Nullable)URLComponent;
Ultimate methods

Aaaand as always - ultimate, super long uber-methods for building your mega query.

+ (NSURL *)ars_queryWithString:(NSString *)URL queryElements:(NSDictionary<NSString *, NSString *> *)queryElements resolveAgainstBaseURL:(BOOL)resolve URLComponent:(NSURLComponents * _Nullable * _Nullable)URLComponent;

+ (NSURL *)ars_queryWithURL:(NSURL *)URL queryElements:(NSDictionary<NSString *, NSString *> *)queryElements resolveAgainstBaseURL:(BOOL)resolve URLComponent:(NSURLComponents * _Nullable * _Nullable)URLComponent;

License

URLQueryBuilder is released under the MIT license. See LICENSE for details.

About

Handy NSURL category, that make URL creation easy and fast.

Resources

Readme
MIT license
Activity

Stars

10 stars

Watchers

0 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.