Skip to content

Instantly share code, notes, and snippets.

View flexaddicted's full-sized avatar

Lorenzo Boaro flexaddicted

View GitHub Profile
// NSArray+FAPMap.h
typedef id(^MapBlock)(id item);
@interface NSArray (FAPMap)
- (NSArray*)fap_map:(MapBlock)mapBlock;
@end
// NSArray+FAPMap.m
function(num) { return num * 3; }
_.map([1, 2, 3], function(num) { return num * 3; });
[[tapGestureRecognizer view] superview];
UITapGestureRecognizer* tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewTapped:)];
tapGestureRecognizer.numberOfTapsRequired = 1;
self.myButton.imageView.userInteractionEnabled = YES;
[self.myButton.imageView addGestureRecognizer:tapGestureRecognizer];
UIImage* image = [UIImage imageNamed:@"my_image"];
[self.myButton setImage:image forState:UIControlStateNormal];
[self.myButton setTitle:@"My button" forState:UIControlStateNormal];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[NSClassFromString(@"WebView") _enableRemoteInspector];
// or [NSClassFromString(@"WebView") performSelector:@selector(_enableRemoteInspector)];
// if the compiler will complain
}
func tableView(tableView: UITableView, didEndEditingRowAtIndexPath indexPath: NSIndexPath) {
if(self.swipeGestureStarted) {
self.swipeGestureStarted = false
self.tableView.selectRowAtIndexPath(self.selectedIndexPath, animated: true, scrollPosition: .None)
}
}
func tableView(tableView: UITableView, willBeginEditingRowAtIndexPath indexPath: NSIndexPath) {
self.swipeGestureStarted = true
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.selectedIndexPath = indexPath
}