Skip to content

Instantly share code, notes, and snippets.

Yonat Sharon yonat

Block or report user

Report or block yonat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yonat
yonat / UISegmentedControl+Vertical.swift
Created Sep 12, 2016
Vertical UISegmentedControl
View UISegmentedControl+Vertical.swift
//
// UISegmentedControl+Vertical.swift
// Make a UISegmentedControl vertical by setting mySegmentedControl.vertical = true
//
// Created by Yonat Sharon on 14/9/14.
// Copyright (c) 2014 Yonat Sharon. All rights reserved.
//
import UIKit
@yonat
yonat / String+substr.swift
Created Sep 3, 2016
Perl style substring for Swift String
View String+substr.swift
extension String {
/**
Perl style substring
- parameter offset: Negative offset starts that far back from the end of the string
- parameter length: Negative length leaves that many characters off the end of the string. Omit to return everything through the end of the string.
*/
func substr(offset: Int, length: Int = 0) -> String {
let start = offset < 0 ? endIndex.advancedBy(offset, limit: startIndex) : startIndex.advancedBy(offset, limit: endIndex)
let end = length > 0 ? start.advancedBy(length, limit: endIndex) : endIndex.advancedBy(length, limit: startIndex)
@yonat
yonat / DoesSomethingInBackground.swift
Created May 2, 2016
iOS background task with all the checks and balances
View DoesSomethingInBackground.swift
class DoesSomethingInBackground
{
var backgroundTaskID: UIBackgroundTaskIdentifier = UIBackgroundTaskInvalid
func beginBackgroundTask() {
guard UIBackgroundTaskInvalid == backgroundTaskID else {return}
backgroundTaskID = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler { () -> Void in
self.endBackgroundTask()
}
}
@yonat
yonat / FBSDKGraphRequest+Paging.h
Last active Apr 5, 2016
Convenience method for Facebook iOS SDK to page through all graph results
View FBSDKGraphRequest+Paging.h
//
// FBSDKGraphRequest+Paging.h
// Facebook Paging Extension
//
// Created by Yonat Sharon on 04.04.2016.
// Copyright © 2016 Yonat Sharon. All rights reserved.
//
#import <FBSDKCoreKit/FBSDKCoreKit.h>
@yonat
yonat / ask.swift
Created Apr 28, 2015
ask() - Show an OK/Cancel modal box that works in both iOS 7 and iOS 8
View ask.swift
/// Show an OK/Cancel modal box that works in both iOS 7 and iOS 8
func ask(title: String, #message: String, #completion: (answer: Bool) -> Void) {
if nil != objc_getClass("UIAlertController".UTF8String) { // use UIAlertController
let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action) -> Void in
completion(answer: false)
})
let okayAction = UIAlertAction(title: "OK", style: .Default, handler: { (action) -> Void in
completion(answer: true)
})
@yonat
yonat / Save-iOS-image-name.md
Last active Mar 16, 2017
Set Image Name in iOS Camera Roll
View Save-iOS-image-name.md
@yonat
yonat / MKStoreKitConfigs.plist
Last active Aug 29, 2015 — forked from MugunthKumar/gist:330fc38b542c96fcecc6
Sample MKStoreKitConfigs.plist
View MKStoreKitConfigs.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Consumables</key>
<dict>
<key>com.steinlogic.dummyconsumable.pack10</key>
<dict>
<key>ConsumableCount</key>
<integer>10</integer>
@yonat
yonat / Badge.swift
Last active Jul 19, 2019
Rounded UILabel and UIButton, Badged UIBarButtonItem
View Badge.swift
//
// Badge.swift
// Extensions for Rounded UILabel and UIButton, Badged UIBarButtonItem.
//
// Usage:
// let label = UILabel(badgeText: "Rounded Label");
// let button = UIButton(type: .System); button.rounded = true
// let barButton = UIBarButtonItem(badge: "42", title: "How Many Roads", target: self, action: "answer")
//
// Created by Yonat Sharon on 06.04.2015.
You can’t perform that action at this time.