Skip to content

Instantly share code, notes, and snippets.

View adel-ezzat's full-sized avatar
😎

Adel ezzat adel-ezzat

😎
View GitHub Profile
@johnhatvani
johnhatvani / UiButton+Block.
Last active October 10, 2021 04:34
Objective-c runtime fun -- A UIButton that takes a block as an action. The cool thing it does is it adds this action as an instance method at runtime.
#import <objc/runtime.h>
typedef void (^buttonAction)(UIButton *sender);
@implementation UIButton (BlockAction)
+ (UIButton *) buttonWithType:(UIButtonType)type andAction:(buttonAction)action forControlEvents:(UIControlEvents)controlEvents; {
UIButton * button = [UIButton buttonWithType:type];
// suppress undeclared selector warning or else '@selector(action:)' will complain.
@ddrccw
ddrccw / hello.h
Created January 14, 2014 04:03
detect jailbreak
//
// Created by ddrccw on 14-1-10.
// Copyright (c) 2014年 ddrccw. All rights reserved.
// refer to http://danqingdani.blog.163.com/blog/static/1860941952012102122847478/
#import <sys/stat.h>
#import <mach-o/dyld.h>
//#import <stdlib.h>
//#import <string.h>
@snikch
snikch / gist:3661188
Created September 6, 2012 23:16
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}