Skip to content

Instantly share code, notes, and snippets.

View odrobnik's full-sized avatar

Oliver Drobnik odrobnik

View GitHub Profile
@odrobnik
odrobnik / gist:df580d010e808c483ce7
Created August 14, 2015 11:02
Fetched Results in Swift
override func numberOfSectionsInTableView(tableView: UITableView) -> Int
{
if let sections = fetchedResultsController.sections
{
return sections.count
}
return 0
}
Entitlements
============
<?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>application-identifier</key>
<string>F6F792KC99.com.productlayer.prodly</string>
<key>aps-environment</key>
@odrobnik
odrobnik / gist:529db10b7030c06e1bbd
Last active August 29, 2015 14:25
How to make this more elegant?
// Variant 1: looks inelegant
override internal func drawRect(rect: CGRect)
{
let context = UIGraphicsGetCurrentContext()
let size = bounds.size
if let gradient = gradient
{
let options = CGGradientDrawingOptions(kCGGradientDrawsAfterEndLocation)
@odrobnik
odrobnik / gist:f1eef9c02488be0e9827
Last active November 14, 2015 09:48
Smallest Turning Angle in Radians - CW rotations position, CCW rotations negative
import Darwin
let π = CGFloat(M_PI)
let _2π = CGFloat(2.0 * π)
extension CGFloat
{
func angleDeltaForShortestRotation(#toAngle: CGFloat) -> CGFloat
{
return remainder(toAngle - self + _2π, _2π)
//
// UIBezierPath+Ring.swift
// WheelBase
//
// Created by Oliver Drobnik on 13.07.15.
// Copyright (c) 2015 Cocoanetics. All rights reserved.
//
import Foundation
import UIKit
import UIKit
import Darwin
@IBDesignable
class DTWheelChart: UIView {
@IBInspectable var days: Int = 28
var shapeLayers : [CAShapeLayer]!
@odrobnik
odrobnik / gist:74dab51d88b63b3de9fe
Created June 30, 2015 09:02
iTunes Connection failing
PBRequester failed with Error Error Domain=NSURLErrorDomain Code=-1200
"An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x13fb6deb0 {_kCFStreamErrorCodeKey=-9824,
NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?,
NSUnderlyingError=0x13c5bb6f0 "An SSL error has occurred and a secure connection to the server cannot be made.",
NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.,
NSErrorFailingURLKey=https://gsp10-ssl.apple.com/use, NSErrorFailingURLStringKey=https://gsp10-ssl.apple.com/use,
_kCFStreamErrorDomainKey=3}
Bug in iOS 7, apparently fixed in iOS 8
on 64bit iOS devices:
NSDecimalNumber *number = [NSDecimalNumber decimalNumberWithMantissa:10665181101155388760u exponent:0 isNegative:NO];
(lldb) po number
10665181101155388760
(lldb) po number.unsignedLongLongValue
@odrobnik
odrobnik / gist:a95d1542438abd1f914a
Created April 23, 2015 08:05
AddressBook Dictionary
var dict = [
kABPersonAddressCityKey: "Vienna",
kABPersonAddressZIPKey: "1110",
kABPersonAddressStreetKey: "Rinnböckstrasse 48/17",
kABPersonAddressCountryKey: "Austria"
]
Error on line 1: "Type of expression is ambiguous without more context"
Error on line 2: "'_' is not convertible to 'StringLiteralConvertible'
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
CGRect lastLineFragmentRect = CGRectZero;
CGFloat lastBaselineOrigin = 0;
CGFloat lineY = 0;
CGFloat lineHeight = 0;