Skip to content

Instantly share code, notes, and snippets.

View ramakser's full-sized avatar
🏠
Working from home

Maksym Rachytskyy ramakser

🏠
Working from home
  • Solar System, Planet Earth
View GitHub Profile
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
- (NSDictionary *)dictionaryRepresentation {
unsigned int count = 0;
// Get a list of all properties in the class.
objc_property_t *properties = class_copyPropertyList([self class], &count);
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithCapacity:count];
for (int i = 0; i < count; i++) {
NSString *key = [NSString stringWithUTF8String:property_getName(properties[i])];
NSString *value = [self valueForKey:key];
#pragma mark UIGestureRecognizerDelegate methods
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view isDescendantOfView:autocompleteTableView]) {
return NO;
}
return YES;
}
class func requestPermission() {
let userNotificationTypes = UIUserNotificationType.Badge | UIUserNotificationType.Alert,
userNotificationSettings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(userNotificationSettings)
}
class IndicatorButton: UIButton {
func setExpanded(expanded: Bool) {
UIView.beginAnimations(nil, context: nil)
UIView.setAnimationDelegate(self)
UIView.setAnimationDuration(0.3)
UIView.setAnimationCurve(UIViewAnimationCurve.EaseIn)
imageView?.transform = CGAffineTransformMakeRotation(CGFloat(expanded ? -M_PI : 2 * M_PI))
UIView.commitAnimations()
}
SCalendar *calendar = [[NSLocale currentLocale] objectForKey:NSLocaleCalendar];
NSUInteger firstDay = [calendar firstWeekday];
- (UIImage *)screenshot
{
CGSize imageSize = CGSizeZero;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsPortrait(orientation)) {
imageSize = [UIScreen mainScreen].bounds.size;
} else {
imageSize = CGSizeMake([UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width);
}
var backgroundUpdateTask: UIBackgroundTaskIdentifier = 0
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
self.backgroundUpdateTask = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler({
self.endBackgroundUpdateTask()
})
}
self.rootView = [self.window.subviews objectAtIndex:0];
if (!self.rootView) {
self.rootView = self;
while (self.rootView.superview != nil) {
self.rootView = self.rootView.superview;
}
}
- (void)willMoveToWindow:(UIWindow *)newWindow {
if(newWindow == nil){
- (UITabBarController *)mainViewController {
return [TyphoonDefinition withClass:UITabBarController.class configuration:^(TyphoonDefinition * definition) {
[definition injectMethod:@selector(setViewControllers:animated:) parameters:^(TyphoonMethod * method) {
[method injectParameterWith:[self mainViewControllers]];
[method injectParameterWith:@NO];
}];
}];
}