Skip to content

Instantly share code, notes, and snippets.

@Shilo
Shilo / CallStackSnippet.m
Created October 29, 2013 06:47
Objective-C snippet for retrieving the call stack information. Useful for finding private classes/methods.
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1];
// Example: 1 UIKit 0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"];
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]];
[array removeObject:@""];
NSLog(@"Stack = %@", [array objectAtIndex:0]);
NSLog(@"Framework = %@", [array objectAtIndex:1]);
NSLog(@"Memory address = %@", [array objectAtIndex:2]);
NSLog(@"Class caller = %@", [array objectAtIndex:3]);
@icleversoft
icleversoft / iosMacros.h
Last active August 3, 2016 07:01
iOS Macros
// App Information
#define AppName [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]
#define AppVersion [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
#define AppDelegate(type) ((type *)[[UIApplication sharedApplication] delegate])
#define NSAppDelegate(type) ((type *)[[NSApplication sharedApplication] delegate])
#define SharedApp [UIApplication sharedApplication]
#define NSSharedApp [NSApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]