Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

// Swift 3
import UIKit
class TestView: UIView {
// MARK: Observers
override func didMoveToWindow() {
@implementation TestView
#pragma mark - Observers
- (void)didMoveToWindow
{
if (self.window) // If self.window != nil, it means view was added to the window
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(test:)
@olxios
olxios / AverageValue.swift
Last active November 29, 2016 12:55
Average array value
// Swift 3
let testArray: [Double] = [15.67, 9.87, 4.56, 3.45, 3.45, 8.76, 6, 1, 20.11]
let average: Double = (testArray as NSArray).value(forKeyPath: "@avg.self") as! Double
print("Average \(average)")
@olxios
olxios / AverageValue.m
Created November 29, 2016 12:30
Average array value
NSArray *testArray = @[@(15.67), @(9.87), @(4.56), @(3.45), @(8.76), @(6), @(1), @(20.11)];
NSNumber *average = [testArray valueForKeyPath:@"@avg.self"];
NSLog(@"Average %@", average);
#import <UIKit/UIKit.h>
@interface GalleryItemsLayout : UICollectionViewLayout
@property (nonatomic, readonly) CGFloat horizontalInset;
@property (nonatomic, readonly) CGFloat verticalInset;
@property (nonatomic, readonly) CGFloat minimumItemWidth;
@property (nonatomic, readonly) CGFloat maximumItemWidth;
@property (nonatomic, readonly) CGFloat itemHeight;
import UIKit
class GalleryItemsLayout: UICollectionViewLayout {
var horizontalInset = 0.0 as CGFloat
var verticalInset = 0.0 as CGFloat
var minimumItemWidth = 0.0 as CGFloat
var maximumItemWidth = 0.0 as CGFloat
var itemHeight = 0.0 as CGFloat
#import <sys/stat.h>
void checkJailbreakSymlinks()
{
NSArray *linksChecks = @[LOO_CRYPT_STR_N("/Applications", 13),
LOO_CRYPT_STR_N("/usr/libexec", 12),
LOO_CRYPT_STR_N("/usr/share", 10),
LOO_CRYPT_STR_N("/Library/Wallpaper", 18),
LOO_CRYPT_STR_N("/usr/include", 12)];
@olxios
olxios / DebugPrint.swift
Last active September 8, 2017 06:59
How to use NSLog and print only for debugging? http://swiftiostutorials.com/use-nslog-debugging/
/// Writes the textual representations of `items` most suitable for
/// debugging, separated by `separator` and terminated by
/// `terminator`, into the standard output.
///
/// The textual representations are obtained for each `item` via
/// the expression `String(reflecting: item)`.
///
/// - Note: To print without a trailing newline, pass `terminator: ""`
///
/// - SeeAlso: `print`, `Streamable`, `CustomStringConvertible`,
@olxios
olxios / Log.h
Last active May 22, 2017 14:37
How to use NSLog and print only for debugging? http://swiftiostutorials.com/use-nslog-debugging/
#import <Foundation/Foundation.h>
@interface Log : NSObject
extern void SSLog(BOOL releaseLog, NSString *format, ...) NS_FORMAT_FUNCTION(2,3);
@end
import Foundation
class GalleryItem {
var itemImage: String
init(dataDictionary:Dictionary<String,String>) {
itemImage = dataDictionary["itemImage"]!
}