This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + (void)invokeMethodNamed:(NSString*)methodName withObject:(id)object classNamed:(NSString*)className | |
| { | |
| id class = NSClassFromString(className); | |
| if (class) { | |
| SEL selector = NSSelectorFromString(methodName); | |
| if ([class respondsToSelector:selector]) { | |
| // static method +(void) | |
| [class performSelector:selector withObject:object]; | |
| } else { | |
| // new instanced method -(void) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Icon with symbol of the beta version instead of the number of badges. | |
| // | |
| // The first thing to note is that the method uses a private API | |
| // so you don't want the code included in your App Store build. | |
| // You can use conditional compilation to achieve this. | |
| // | |
| // original post from @sgaw | |
| // | |
| - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // UIWebView asynchronous javascript call | |
| // | |
| // javascript function | |
| NSString *javascriptString = @"my_function();"; | |
| // allocated UIWebView | |
| [webView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:javascriptString waitUntilDone:NO] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @implementation NSNumber (Randomizer) | |
| + (NSNumber*)randomNumberWithMin:(NSInteger)min max:(NSInteger)max | |
| { | |
| if (min>max) { | |
| int tempMax=max; | |
| max=min; | |
| min=tempMax; | |
| } | |
| int randomy=arc4random() % (max-min+1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // How to manage the image asynchronously from a UIImagePickerController | |
| - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info | |
| { | |
| // hide UIImagePickerController | |
| [picker dismissViewControllerAnimated:YES completion:^{ | |
| dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{ | |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ | |
| UIImage *originalImage = [info objectForKey:UIImagePickerControllerOriginalImage]; | |
| if (photo) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // SDWebImage author: @Olivier_Poitrey | |
| // source code https://github.com/rs/SDWebImage | |
| // | |
| // Extension author: @DaniloPriore | |
| // | |
| #import "SDWebImageCompat.h" | |
| #import "SDWebImageManager.h" | |
| #import "UIImageView+WebCache.h" | |
| #import "objc/runtime.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + (UIImage*)imageFromIconApp { | |
| NSString *iconName = nil; | |
| NSDictionary *info = [[NSBundle mainBundle] infoDictionary]; | |
| NSArray *iconfiles = [info valueForKeyPath:@"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles"]; | |
| if (iconfiles == nil || [iconfiles count] == 0) iconfiles = [info objectForKey:@"CFBundleIconFiles"]; | |
| if (iconfiles != nil && [iconfiles count] > 0) { | |
| iconName = [iconfiles objectAtIndex:0]; | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // User-Agent for all UIWebView in your app, originally posted by @_kims | |
| NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3", @"UserAgent", nil]; | |
| [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // NSObject+NSDictionary.h | |
| // | |
| @interface NSObject (NSDictionary) | |
| - (void)setValuesWithDictionary:(NSDictionary*)dict; | |
| @end | |
| // | |
| // NSObject+NSDictionary.m | |
| // |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // force close | |
| [[FBSession activeSession] closeAndClearTokenInformation]; | |
| [[FBSession activeSession] close]; | |
| [FBSession setActiveSession:nil]; | |
| // remove FB cookie | |
| NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; | |
| for (NSHTTPCookie *cookie in [storage cookies]) { | |
| NSString *domainName = [cookie domain]; | |
| NSRange domainRange = [domainName rangeOfString:@"facebook"]; |