• This repository has been archived on 11/Nov/2021
  • Stars
    star
    233
  • Rank 172,230 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 12 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

Objective-C utilities and shorthands.

Overline 0.2.0

Objective-C utilities and shorthands.

Overline is not clone of other language features. Simple and clean Objective-C.

Usage

setup with cocoapods.

pod 'Overline'

import Overline.h

#import "Overline.h"

with BlocksKit

pod 'BlocksKit'
pod 'Overline-BlocksKit'

Ignored duplicate methods: each map reduce filter reject

Features

NSArray

NSArray+Initialize

NSArray *array = [NSArray arrayWithRangeFrom:0 to:10];
// @[@0, @1, @2, @3, @4, @5, @6, @7, @8, @9]

NSArray *array2 = [NSArray arrayWithRangeFrom:0 to:-10 step:2];
// @[@0, @-2, @-4, @-6, @-8]
  • arrayWithRangeFrom:to:
  • arrayWithRangeFrom:to:step:

NSArray+Enumeration

NSArray *mapped = [@[@1,@2,@3,@4,@5,@6] mappedArrayUsingBlock:^id(id obj, NSUInteger idx) {
    if ([obj integerValue] % 2 == 0) {
        return obj;
    }
    return nil;
}];
// @[@2,@4,@6]
  • each
  • map mappedArrayUsingBlock
  • reduce reducedObjectByBlock
  • find objectUsingBlock
  • filter filteredArrayUsingBlock
  • reject rejectedArrayUsingBlock

NSArray+Random

NSArray *shuffled = [@[@1,@2,@3,@4,@5,@6] shuffledArray];
  • shuffle shuffledArray
  • anyObject

NSArray+Reverse

NSArray *reversed = [@[@1,@2,@3,@4,@5,@6] reversedArray]; 
// @[@6,@5,@4,@3,@2,@1]
  • reverse reversedArray
  • objectAtReversedIndex

NSArray+Selector

  • firstObject

NSArray+SubArray

  • subarrayFromIndex:
  • subarrayFromIndex:length:
  • subarrayToIndex:
  • uniqueObjects
  • uniqueObjectsUsingEqualsBlock

NSArray+Difference

  • difference arrayDifferenceWithArray
  • unionise arrayByUnionisingArray

NSArray+Shorthand

  • isEmpty

NSArray+Sorting

  • arraySortedDescending:
  • arraySortedAsc
  • arraySortedDesc

NSMutableArray

NSMutableArray+Shorthands

NSMutableArray *marray = [NSMutableArray arrayWithArray:@[@1,@2,@3]];
[marray insertObjects:@[@4,@5,@6] atIndex:1];
  • insertObjects:atIndex:

NSMutableArray+Sorting

  • sortDescending:
  • sortAsc
  • sortDesc

NSDate

NSDate+Components

Class Methods
  • currentWeekday
  • currentHour
  • currentMinute
  • currentSecond
  • currentDay
  • currentMonth
  • currentYear
  • commonDateComponentsForNow
  • timeComponentsForNow
Instance Methods
  • weekday
  • hour
  • minute
  • second
  • day
  • month
  • year
  • commonDateComponents
  • timeComponents

NSDictionary

NSDictionary+Selector

NSDate *date = [JSON objectForKey:@"date8601" transformBlock:^id(id obj) {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy/MM/dd HH:mm:ss Z"];
    return [formatter dateFromString:obj];
}];
  • objectForKey:transformBlock:
  • numberForKey:
  • stringForKey:
  • arrayForKey:
  • dictionaryForKey:
  • dateForKey:
  • dateForKey:usingFormat:
  • since1970DateForKey:
  • timestampForKey:
  • boolObjectForKey:withTrueValue:
  • boolForKey:withTureValue:
  • boolForKey:
  • intForKey:
  • integerForKey:
  • unsignedIntForKey:
  • unsignedIntegerForKey:
  • longForKey:
  • unsignedLongForKey:
  • longLongForKey:
  • unsignedLongLongForKey:
  • doubleForKey:
  • floatForKey:

NSDictionary+Enumeration

NSDictionary *dic = @{
        @"a" : @1,
        @"b" : @2,
        @"c" : @3,
        @"d" : @4
};

NSDictionary *filtered = [dic dictionaryFilteredByKeyUsingBlock:^BOOL(NSString *key) {
    return [key isEqualToString:@"a"];
}]; // @{@"a":@1}
  • each:
  • map mappedDictionaryUsingBlock
  • arrayMap mappedArrayUsingBlock
  • filterKey dictionaryFilteredByKeyUsingBlock
  • rejectKey dictionaryRejectedByKeyUsingBlock
  • filterObject dictionaryFilteredByObjectUsingBlock
  • rejectObject dictionaryRejectedByObjectUsingBlock
  • merge dictionaryByMergingDictionary
  • reduce: reducedObjectUsingBlock:memo:
  • queryString stringByFormattingQuery

NSDictionary+Path

/*
@{
    @"error" : @{
        @"message" : @"msg"
    }
}
*/
NSString *s = [dic objectForPath:@"error.message"];
  • objectForPath:

NSSet

NSSet+Enumeration

NSSet *set = [NSSet setWithArray:@[@1,@2,@3,@4,@5,@6]];
NSSet *mapped = [set mappedSetUsingBlock:^id(id obj, NSUInteger idx) {
    if ([obj integerValue] % 2 == 0) {
        return obj;
    }
    return nil;
}];
  • each
  • map mappedSetUsingBlock
  • reduce reducedObjectByBlock
  • filter filteredSetUsingBlock
  • reject rejectedSetUsingBlock

NSString

NSString+Components

[@"hoge=fuga&piyo=foo" componentsSeparatedByInnerString:@"=" andOuterString:@"&"];
/* 
@{
    @"hoge" : @"fuga",
    @"piyo" : @"foo"
};
*/
  • componentsSeparatedByInnerString:andOuterString:

NSString+RegularExpression

[@"https?" testInString:urlString];
  • rangeOfFirstMatchInString:
  • rangeOfFirstMatchInString:options:
  • matchesInString:
  • matchesInString:options:
  • testInString:
  • testInString:options:
  • replace:newString: stringByReplacingOccurrencesOfRegExpPattern:withString
  • replace:newString:options: stringByReplacingOccurrencesOfRegExpPattern:withString:options:
  • replace:template: stringByReplacingOccurrencesOfRegExpPattern:withTemplate:
  • replace:template:options: stringByReplacingOccurrencesOfRegExpPattern:withTemplate:options:

NSString+Hash

[@"hoge" md5]; // @"ea703e7aa1efda0064eaa507d9e8ab7e"
  • sha256
  • stringByHashingSha256
  • md5
  • stringByHashingMD5

NSString+URLEncode

  • URLEncode
  • stringByEncodingURL
  • URLDecode
  • stringByDecodingURL

NSString+Shorthand

  • trim
  • trim: - Trim character set in a given string

NSString+JSON

NSString *JSONString = @"{\"hoge\" : \"fuga\" }";
id json = [JSONString jsonObject];
  • JSON jsonObject

NSString+Base64Encode

[@"a" stringByEncodingBase64]; // @"YQ=="
[@"YQ==" stringByDecodingBase64]; // @"a"
  • encodeBase64 stringByEncodingBase64
  • decodeBase64 stringByDecodingBase64
  • dataUsingDecodingBase64

NSData

NSData+Base64Encode

  • base64Encode stringUsingEncodingBase64

NSURL

NSURL+Components

  • queryComponents

NSURL+Directories

NSURL *pdfURL = [NSURL URLForUserDirectoryWithAppendedPath:@"myDoc.pdf"];
NSURL *userImageFolderURL = [NSURL URLForUserDirectoryWithAppendedPath:@"images"];
  • URLForDirectory:domainMask:
  • URLForApplicationSupportDataDirectory
  • URLForApplicationSupportWithAppendedPath:
  • URLForUserDirectory
  • URLForUserDirectoryWithAppendedPath:
  • URLForDocumentDirectory;
  • URLForDocumentDirectoryWithAppendedPath:;

NSBundle

NSBundle+Shorthand

  • JSONForResourceName

NSNumber

NSNumber+Equals

[@1 isEqualToInteger:1];
  • isEqualToInt:
  • isEqualToInteger:
  • isEqualToUnsignedInt:
  • isEqualToUnsignedInteger:
  • isEqualToLong:
  • isEqualToLongLong:
  • isEqualToUnsignedLong:
  • isEqualToUnsignedLongLong:
  • isEqualToDouble:
  • isEqualToFloat:

NSDateFormatter

NSDateFormatter+Shothand

  • userDefaultFormatter
  • dateFormatterWithCalendarIndetifiter:localeIdentifiter:timeZoneAbbreviation:

NSObject

NSObject+Equals

[[NSNull null] isNullObject]; // YES
[[NSArray array] isNullObject]; // NO
  • isNullObject
  • isArray
  • isDictionary
  • isSet
  • isString
  • isNumber

NSNull

NSNull+Natural

Provide NSNull like nil

NSDictionary *dic = @{
        @"null-key" : [NSNull null]
};
[[dic objectForKey:@"null-key"] objectForKey:@"empty"]; // nil

※ This feature disable on default. Define OV_USE_NATURAL_NULL, if use this feature.

#define OV_USE_NATURAL_NULL
#import "Overline.h"

Credits

Be sure to thank these contributors:

Coding rules

  • Write tests.
  • Objective-C style naming.
    • and shorthands.

More Repositories

1

NLTHTTPStubServer

Fake server for iOS testing.
Objective-C
73
star
2

NLTQuickCheck

like haskell quickcheck
Objective-C
45
star
3

monapt

Like Scala Monads for TypeScript and JavaScript
TypeScript
31
star
4

typescript-dddbase

TypeScript DDD base modules
TypeScript
27
star
5

ForHeadHunters

こんにちは!
17
star
6

ebifly

Web Remote Debugger
JavaScript
11
star
7

nice-catch-precure

ナイスキャッチ!プリキュア!
10
star
8

UIWebView-UserAgent

fetching UIWebViews UserAgent
Objective-C
10
star
9

Flow.m

Simple async processing with pass/miss. Inspired by flow.js.
Objective-C
7
star
10

typescript-proj

TypeScript project template.
TypeScript
6
star
11

NSMutableArrayRearrangingExtensions

a extensions for NSMutableArray
Objective-C
6
star
12

fivefold

View and routing
TypeScript
5
star
13

my-xcode-templates

my xcode4 templates
Objective-C
5
star
14

AsyncTestSupporter

Like GHUnit AsyncTestCase functions.
Objective-C
5
star
15

staccato

Dependency injection for Typescript
TypeScript
4
star
16

octone

third party github client for iPhone
Objective-C
4
star
17

AlertNinja

Invisible UIAlertView and spying.
Objective-C
4
star
18

Plasma

[WIP] Model and APIClient layer freamework for CocoaTouch.
Objective-C
3
star
19

Podfile

よく使うPod達
Ruby
3
star
20

sync-app

Parse.comを使ったユーザーデータを同期するだけのウェブアプリ
JavaScript
3
star
21

Octopress-Theme-Blaze

= Blaze = , a my blog theme for Octopress
JavaScript
3
star
22

ios-tdd

TDD的にiOSアプリケーション開発してみる
Objective-C
2
star
23

mocha-testem-htmlcov

JavaScript
2
star
24

kaede

nodejs ircbot
JavaScript
2
star
25

GithubOAuthExample

github oauth example
Objective-C
2
star
26

typescript-ddd-lazyload

lazyloadの実装サンプル
TypeScript
2
star
27

Gruntfile

Base Gruntfiles
CoffeeScript
2
star
28

StoryBoard-Sliding

http://yaakaito.org/blog/2013/04/25/sliding-view-with-stroyboard/
Objective-C
2
star
29

HullToRefresh

a joke.
Objective-C
1
star
30

sistere

html5 prezention
JavaScript
1
star
31

octopress-sources

1
star
32

iOSTesting

iOSのテストを練習したりする題材
Swift
1
star
33

EventEmitter.d.ts

d.ts for https://github.com/Wolfy87/EventEmitter
1
star
34

octopress-degisn

1
star
35

action-request-review

JavaScript
1
star
36

typebone

Backbonejs clone of requirements for TodoMVC with TypeScript
TypeScript
1
star
37

grunt-coffeelint

A grunt task of coffeelint.
JavaScript
1
star
38

postmessage-unittest

TypeScript
1
star
39

cd-lastest-simulator

cd lastest used ios simulator
Shell
1
star
40

VerifyViewTips

GHVerifyView tips
Objective-C
1
star
41

build-framework.sh

.framework形式作りたいときのカスタムシェルスクリプトの例
Shell
1
star
42

re-typescript-mvc

TypeScript
1
star
43

AttributedStringExample

iOS6からのAttributedStringの説明用プロジェクト
Objective-C
1
star