Skip to content

Instantly share code, notes, and snippets.

View yonat's full-sized avatar

Yonat Sharon yonat

View GitHub Profile
@yonat
yonat / BackgroundTaskWrapper.swift
Last active November 28, 2021 17:44
iOS background task with all the checks and balances
class BackgroundTaskWrapper {
private var taskID = UIBackgroundTaskIdentifier.invalid
var cancelAction: (() -> Void)?
func begin() {
guard .invalid == taskID else { return }
taskID = UIApplication.shared.beginBackgroundTask { [weak self] in
self?.cancelAction?()
self?.end()
}
@yonat
yonat / FBSDKGraphRequest+Paging.h
Last active April 5, 2016 07:09
Convenience method for Facebook iOS SDK to page through all graph results
//
// 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 / Save-iOS-image-name.md
Last active March 16, 2017 10:01
Set Image Name in iOS Camera Roll
@yonat
yonat / MKStoreKitConfigs.plist
Last active August 29, 2015 14:18
Sample 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 December 22, 2022 09:40
Rounded UILabel and UIButton, Badged UIBarButtonItem
//
// 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.