Skip to content

Instantly share code, notes, and snippets.

- (void)testAlert1:(id)sender
{
UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Error!"
message:@"Test error message"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"Dismiss"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
NSLog(@"Dismiss button tapped!");
@IBAction func testAlert1() {
let controller = UIAlertController(title: "Error!", message: "Test error message", preferredStyle: .Alert)
let alertAction = UIAlertAction(title: "Dismiss", style: .Destructive) { (action) in
print("Dismiss button tapped!")
}
controller.addAction(alertAction)
presentViewController(controller, animated: true, completion: nil)
#import <Foundation/Foundation.h>
@interface GalleryItem : NSObject
@property (nonatomic, strong) NSString *itemImage;
+ (instancetype)galleryItemWithDictionary:(NSDictionary *)dictionary;
@end
import Foundation
class GalleryItem {
var itemImage: String
init(dataDictionary:Dictionary<String,String>) {
itemImage = dataDictionary["itemImage"]!
}
@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
@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`,
#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)];
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 <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;
@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);