Skip to content

Instantly share code, notes, and snippets.

异常处理:
void UncaughtExceptionHandler(NSException *exception) {
NSArray *arr = [exception callStackSymbols];
NSString *reason = [exception reason];
NSString *name = [exception name];
NSString *url = [NSString stringWithFormat:@"=============异常崩溃报告=============\nname:\n%@\nreason:\n%@\ncallStackSymbols:\n%@",
name,reason,[arr componentsJoinedByString:@"\n"]];
@fragno
fragno / gist:ff2fffb698e9bfc6cdbd6ff1bd157771
Last active June 13, 2017 14:28
iOS屏蔽信号,防止无堆栈退出
static void ignoring_signals() {
signal(SIGINT,SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGQUIT,SIG_IGN);
signal(SIGPIPE,SIG_IGN);
signal(SIGTTOU,SIG_IGN);
signal(SIGTTIN,SIG_IGN);
signal(SIGCHLD,SIG_IGN);
signal(SIGTERM,SIG_IGN);
@fragno
fragno / combine_static_libraries.sh
Created September 13, 2016 13:17 — forked from evands/combine_static_libraries.sh
Combine multiple .a static libraries, which may each have multiple architectures, into a single static library
#!/bin/sh
# Combined all static libaries in the current directory into a single static library
# It is hardcoded to use the i386, armv7, and armv7s architectures; this can easily be changed via the 'archs' variable at the top
# The script takes a single argument, which is the name of the final, combined library to be created.
#
# For example:
# => combine_static_libraries.sh combined-library
#
# Script by Evan Schoenberg, Regular Rate and Rhythm Software
@fragno
fragno / iOS7PresentSemiTransVC.m
Last active June 7, 2016 06:49
iOS7以上present半透明的vc
- (void)presentOverViewController:(ASViewController *)viewController
{
if ([[UIDevice currentDevice].systemVersion integerValue] >= 8) {
//For iOS 8
viewController.providesPresentationContextTransitionStyle = YES;
viewController.definesPresentationContext = YES;
viewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[viewController presentViewController:self animated:NO completion:nil];
}
else
@fragno
fragno / UIWebView+Screenshot.m
Created November 14, 2015 10:53 — forked from fireblue/UIWebView+Screenshot.m
Find a certain element in UIWebView and make a screenshot. :)
-(UIImage *)screenShot
{
CGRect originalFrame = self.frame;
CGPoint originalOffset = self.scrollView.contentOffset;
CGSize entireSize = [self sizeThatFits:CGSizeZero];
[self setFrame: CGRectMake(0, 0, entireSize.width, entireSize.height)];
CGRect rect = [self positionOfElementWithId:@"post1"];
//如果没有找到这个元素,就取整个页面
if (rect.origin.y != 0) {
@fragno
fragno / weak-strong-self.m
Last active June 13, 2017 14:29
xcode snippet
__weak typeof(self) weakSelf = self;
__strong typeof(self) strongSelf = weakSelf;
if (strongSelf) {
<#statement#>
}
@fragno
fragno / UIView+i7Rotate360.h
Created May 11, 2015 09:09
just like activity indicator, but rotate uiview, u can customize loading image
//
// UIView+i7Rotate360.h
// include7 AG
//
// Created by Jonas Schnelli on 01.12.10.
// Copyright 2010 include7 AG. All rights reserved.
//