Skip to content

Instantly share code, notes, and snippets.

View virasio's full-sized avatar

Victor Surikov virasio

  • EPAM
  • Türkiye
  • 01:06 (UTC +03:00)
View GitHub Profile
import UIKit
/// Navigation Controller that forwards `prefersStatusBarHidden` and `preferredStatusBarStyle` properties from `topViewController`.
class PSBNavigationController: UINavigationController {
override var viewControllers: [UIViewController] {
didSet {
setNeedsStatusBarAppearanceUpdate()
}
}
@virasio
virasio / UIViewController+ReplaceRoot.h
Last active March 8, 2016 07:37
Method replace current root view controller to new view controller with animation and different orientations
//
// UIViewController+ReplaceRoot.h
//
// Created by Victor Surikov on 08/03/16.
// Copyright © 2016 Victor Surikov. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIViewController (ReplaceRoot)
@virasio
virasio / GPUImageMirrorFilter.h
Created February 25, 2015 10:16
Mirror filter for GPUImage
//
// GPUImageMirrorFilter.h
//
#import <GPUImage/GPUImageFilter.h>
@interface GPUImageMirrorFilter : GPUImageFilter {
GLint verticalMirrorUniform, horizontalMirrorUniform;
}
@interface NSLocale (Utilities)
@property (nonatomic, readonly) NSDictionary *ISOLanguages;
+ (NSString *)getCountryNameForCode:(NSString *)countryCode;
+ (NSString *)getLanguageNameForCode:(NSString *)languageCode;
+ (NSString *)getLocalizedLanguageNameForCode:(NSString *)languageCode
@virasio
virasio / AppDelegate.m
Created April 10, 2014 08:14
NSData Apple Push Notification Device Token to NSString
// ...
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString * token = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
// ...
}
@virasio
virasio / NSURL+Dictionaries.h
Last active August 29, 2015 13:58
NSURL+Dictionaries — Returns properties query and fragment of NSURL as NSDictionary
@interface NSURL (Dictionaries)
@property (nonatomic, readonly) NSDictionary *queryDictionary;
@property (nonatomic, readonly) NSDictionary *fragmentDictionary;
- (NSURL *)URLByAppendingQueryParameters:(NSDictionary *)parameters;
@end
@virasio
virasio / Singleton.h
Last active December 2, 2019 03:42
Singleton (Objective-C with ARC)
@interface MySingleton : NSObject
// ...
+ (instancetype) sharedInstance;
+ (instancetype) alloc __attribute__((unavailable("alloc not available, call sharedInstance instead")));
- (instancetype) init __attribute__((unavailable("init not available, call sharedInstance instead")));
+ (instancetype) new __attribute__((unavailable("new not available, call sharedInstance instead")));
@virasio
virasio / uuid.m
Created March 6, 2014 07:07
UUID Generator (Objective-C)
+ (NSString*)getUUID
{
CFUUIDRef newUniqueId = CFUUIDCreate(kCFAllocatorDefault);
NSString * uuidString = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, newUniqueId);
CFRelease(newUniqueId);
return uuidString;
}