• Stars
    star
    153
  • Rank 243,368 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 8 years ago

Reviews

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

Repository Details

Swift's Sugar. Heavily inspired on Objc Sugar(https://github.com/supermarin/ObjectiveSugar)

Note: Used as an exercise mainly, still you can make use of it of course

Inspiration

Swift Sugar is heavily inspired on ObjectiveSugar.

Documentation

Int extensions

3.times {
    println("Hello!")
}
// Hello!
// Hello!
// Hello!
3.timesWithIndex {
    index in println(index)
}
// 0
// 1
// 2
3.upTo(5) {
    index in println(index)
}
// 3
// 4
5.downTo(0) {
    index in println(index)
}
// 5
// 4
// 3
// 2
// 1

Array functions

[1,2,3,4].initial(3)
// [1,2,3]
[1,2,3,4].initial()
// [1]
[1,2,3,4].drop {$0 % 2 ==0}
// [2,4]
[1,2,3,4].remove(2)
// [3,4]
[1,2,3,4].minimum()
// 1
[1,2,3,4].maximum()
// 4
[1,2,3,4,1].numberTimesRepeated(1)
// 2

String functions

"Swift programming".length
// 17
"Swift programming"[1]
// w
"Swift programming"[-4]
// m
String.join(["S","w","i"])
//Swi
String.join("S","w","i","f","t")
//Swift
"Swift programming".split()
//["Swift", "programming"]
"Swift programming".split(delimiter:"r")
//["Swift p", "og", "amming"]
"Swift programming".indexOfString("mm")
// 12
"Swift programming".toCharacterArray()
//["S","w","i","f","t"," ","p","r","o","g","r","a","m","m","i","n","g"]
"Swift programming".reverse()
//gnimmargorp tfiwS

Swift Sugar (Global functions)

let x : [(Int,Int)] = zip([1,2,3,4,5], [1,2,3])
// [(1,1),(2,2),(3,3)]

More Repositories

1

UIViewController-Swizzled

Used to print the structure of your application as you use it
Objective-C
847
star
2

Receiver

Swift µframework implementing the Observer pattern 📡
Swift
239
star
3

Reactor

Powering your RAC architecture
Swift
184
star
4

OptionalExtensions

Swift µframework with extensions for the Optional Type
Swift
182
star
5

iOSArchitecture

Sample project showing a common architecture I use when creating iOS Projects
Objective-C
157
star
6

Tangerine

Swift µframework for fetching images 🍊
Swift
149
star
7

Rinku

A simple networking library
Swift
43
star
8

KirKos

Focus on the most important
Objective-C
34
star
9

SaferFonts

Avoiding potential mistypes while using fonts programatically in Swift
Swift
30
star
10

RPNSURLConnection-Swizzled

NSURLConnection's category for the request and stack trace output
Objective-C
26
star
11

RPDynamicWarningView

A simple warning view that takes advantage of UIKit Dynamics
Objective-C
22
star
12

NSURLConnection-Blocks

Category that allows the dev to specify blocks for the success and failure cases
Objective-C
13
star
13

UITextField-DelegationBlocks

Add blocks, as per a single instance basis, to your UITextFields
Objective-C
12
star
14

NSObject-Dealloc

Category used to know when your object has been deallocated
Objective-C
7
star
15

8472

Strava client, with focus activities analysis. 🏃‍♂️
Swift
6
star
16

JSaaS

Jaden Smith as a Service
Elixir
6
star
17

NSPortoWorkshop

A detailed description about a potential Workshop that could be organised in Porto, Portugal.
5
star
18

SliderController

Objective-C
5
star
19

fartlek

Strava Webhooks + APNS
Python
5
star
20

RPGallery

Gallery used to upload pictures
Objective-C
4
star
21

TeamGen

Generating balanced teams 🚀🏈
Swift
4
star
22

OctifyIssues

Used as Issues Tracker for the App Octo Alarm
3
star
23

FootballTeamGenerator

...because just random is not good enough
Swift
3
star
24

RuiAAPeres

2
star
25

ReversePolishNotation-Swift

Reverse Polish Notation done in Swift, based on http://learnyousomeerlang.com/functionally-solving-problems#rpn-calculator
Swift
2
star
26

but_the_android_team_uses_RxJava

this is a parody
Swift
2
star
27

OctifyPush

APNS for my iOS App (Octify)
Go
2
star
28

TestingFRP

Some benchmarks
Swift
2
star
29

SquareStock

Square Stock
Objective-C
1
star
30

Refactoring

Swift
1
star
31

Franz

Swift
1
star
32

Reading18

A list of material (articles + books) I read + wrote in 2018.
1
star
33

swiftAveiroFP

FP stuff with Argo Fun
Swift
1
star
34

principles

1
star
35

PromisesPlayground

Objective-C
1
star