• Stars
    star
    260
  • Rank 157,189 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 16 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Utilities and categories for Objective-C

GHKit

The GHKit framework is a set of extensions and utilities for Mac OS X and iOS.

Podfile

pod "GHKit"

Usage

GHKit defines various categories and general purpose utilities.

For example, parsing date strings, date math, string manipulations, URL dictionary formatting, etc. Some examples are below.

All categories are namespaced with gh_ to avoid conflicts.

Import:

#import <GHKit/GHKit.h>

Dates:

GHNSDate+Formatters.h: Date parsers, formatting and formatters for ISO8601, RFC822, HTTP (RFC1123, RFC850, asctime) and since epoch.

NSDate *date = [NSDate gh_parseISO8601:@"2010-10-07T04:25Z"];
NSString *dateString = [date gh_formatHTTP]; // Formatted like: Sun, 06 Nov 1994 08:49:37 GMT"
NSDate *date = [NSDate gh_parseTimeSinceEpoch:@(1234567890)];

GHNSDate+Utils.h: For time ago in words and date component arithmentic (adding days), tomorrow, yesterday, and more.

NSDate *date = [NSDate date];
[date gh_isToday]; // YES
[[date gh_yesterday] gh_isToday]; // NO

date = [date gh_addDays:-1];
[date gh_wasYesterday]; // YES

[date gh_timeAgo:NO]; // @"1 day"

Arrays:

GHNSArray+Utils.h: Random object, safe object at index, uniq, compact

[@[@(1), @(2), @(3)] gh_random]; // Random object
[@[@(1), @(1), @(3)] gh_uniq]; // @[@(1), @(3)]
[@[] gh_objectAtIndex:0]; // nil (Safe objectAtIndex)
[@[@(1), NSNull.null] gh_compact]; // @[@(1)]

Dictionaries:

GHDictionary+Utils.h:

NSDictionary *dict = @{@"key1": @(2), @"key2": @(3.1), @"key3": @YES};
NSString *JSONString = [dict gh_toJSON:NSJSONWritingPrettyPrinted error:nil];

Strings:

GHNSString+Utils.h: Stripping, reversing, counting and more.

[NSString gh_isBlank:@"  "]; // YES
[NSString gh_isBlank:nil]; // YES
[@"  some text " gh_strip]; // @"some text"
[@" " gh_isPresent]; // NO
[@"abc" gh_isPresent]; // YES
[@" " gh_present]; // nil
[@"some text" gh_present]; // @"some text"

[@"abc" gh_reverse]; // @"cba"

[@"ababababcde" gh_count:@"ab"]; // 4 (@"ab" appears 4 times)

[NSString gh_localizedStringForTimeInterval:30]; // "half a minute"
[NSString gh_abbreviatedStringForTimeInterval:30]; // @"30s"

[@"WWW.test.com" gh_startsWith:@"www." options:NSCaseInsensitiveSearch]; // YES
[@"foo:bar" gh_lastSplitWithString:@":" options:NSCaseInsensitiveSearch]; // @"bar"

[@"e̊gâds" gh_characters]; // @[@"e̊", @"g", @"â", @"d", @"s"];

URLs:

GHNSURL+Utils.h: Encoding, escaping, parsing, splitting out or sorting query params, and more.

NSDictionary *dict = [@"c=d&a=b" gh_queryStringToDictionary]; // Dictionary with a => b, c => d
[NSDictionary gh_dictionaryToQueryString:dict sort:YES]; // @"a=b&c=d"

Colors:

GHUIColor+Utils.h: Colors from hex, color space changes, darken.

UIColor *color = GHUIColorFromRGB(0xBC1128);
GH_HSV hsvColor = [color gh_hsv];
UIColor *darkenedColor = [color gh_darkenColor:0.1]; // Darken 10%

And more...

More Repositories

1

yajl-objc

Objective-C bindings for YAJL (Yet Another JSON Library) C library
C
670
star
2

CaptureRecord

User + Screen Recording iOS SDK
Objective-C
342
star
3

as3httpclient

HTTP Client for AS3
ActionScript
243
star
4

ffmpeg-iphone-build

Build scripts for building ffmpeg on iPhone
Shell
221
star
5

MPMessagePack

MessagePack implementation for Objective-C / msgpack.org[Objective-C]
Objective-C
179
star
6

capitate

Capistrano recipes, plugins and templates.
Ruby
78
star
7

NAChloride

Libsodium for Objective-C
Objective-C
67
star
8

font-detect-js

Font detection using Javascript and Flash
HTML
64
star
9

xcode-themes

XCode Themes
49
star
10

shrub

S3 Proxy for Google App Engine
Python
45
star
11

airake

Rake tasks and generators for Adobe AIR
Ruby
14
star
12

GHGLUtils

OpenGL Utilities for OSX and iOS
Objective-C
14
star
13

GHODictionary

Ordered dictionary
Objective-C
13
star
14

GRUnit

Unit testing for iOS
Objective-C
12
star
15

json-objc-perf

Basic perf tests for Objective-C JSON frameworks
Objective-C
12
star
16

turing-fluid-osx

OSX version of Turing Fluid demo http://cake23.de/turing-fluid.html
Objective-C
10
star
17

KBPGP

PGP for iOS/OSX using kbpgp.js and JavaScriptCore
JavaScript
10
star
18

TSTripleSec

Objective-C implementation of TripleSec
Objective-C
10
star
19

NACrypto

Advanced crypto library. You may want to use NAChloride (libsodium/NaCl) instead.
C
6
star
20

KBKeybaseAPI

Keybase.io API client for iOS/OSX
Objective-C
6
star
21

PointSpriteShader

Example OS X OpenGL project for displaying variable size point sprites with shaders
Objective-C
4
star
22

FFProcessing

C++
3
star
23

GHUITable

Extensions for UITableView and UICollectionView
Objective-C
3
star
24

YOCView

Simplifying UIView and UIViewController interactions.
Objective-C
3
star
25

gabriel.github.com

2
star
26

GHBigNum

Bignum for Obj-C (OpenSSL)
Objective-C
2
star
27

pre-commit-golang

Shell
2
star
28

status-back

For debugging connections
Python
1
star