Skip to content

Instantly share code, notes, and snippets.

@sanketfirodiya
sanketfirodiya / gist:876e82713619e44abc5c
Last active August 29, 2015 14:03
Check iOS version
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
@sanketfirodiya
sanketfirodiya / gist:9cf269d301c7c5673de5
Last active August 29, 2015 14:03
MBProgress show text
MBProgressHUD* hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
[hud setMode:MBProgressHUDModeText];
[hud setLabelText:@"Running latest version, sweet!"];
[hud hide:YES afterDelay:2.0];
-fno-objc-arc
@sanketfirodiya
sanketfirodiya / gist:4113cf197b38894c70d6
Last active August 29, 2015 14:04
Symbolicate stack trace to objective-c source code
export DEVELOPER_DIR="/Applications/XCode.app/Contents/Developer"
alias symbolicate="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash -v"
symbolicate -o "AppCrash.txt" "CrashLog-E06B8427-F47D-487F-80B7-0D84733ED435-6032-000007E67F99442A.txt" "MyApp.app"
@sanketfirodiya
sanketfirodiya / gist:5f0d3d9e62fa07dadb8b
Last active August 29, 2015 14:04
Determine if view is currently shown on screen
if (viewController.isViewLoaded && viewController.view.window) {
// viewController is visible
}
@sanketfirodiya
sanketfirodiya / gist:b0a0f4f8b4c0f40bb52a
Last active August 29, 2015 14:04
Write logs to a file
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName =[NSString stringWithFormat:@"%@.log",[NSDate date]];
NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:fileName];
freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
@sanketfirodiya
sanketfirodiya / Terminal commands
Last active November 28, 2016 08:48
Testing APNS certificates in PHP
openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem
openssl pkcs12 -nocerts -out PushChatKey.pem -in PushChatKey.p12
cat PushChatCert.pem PushChatKey.pem > ck.pem
php simplepush.php
telnet gateway.sandbox.push.apple.com 2195
@sanketfirodiya
sanketfirodiya / gist:149920642ea90eb73616
Created July 31, 2014 05:16
Determine indexPath based on gesture
CGPoint location = [gesture locationInView:self.uiTableView];
NSIndexPath *swipedIndexPath = [self.uiTableView indexPathForRowAtPoint:location];
UITableViewCell *swipedCell = [self.uiTableView cellForRowAtIndexPath:swipedIndexPath];
@sanketfirodiya
sanketfirodiya / gist:67c844d2f0af45a0af13
Created August 1, 2014 15:47
Rounded edge for UIImage
imageView.image = [UIImage imageWithData:fileData];
imageView.layer.cornerRadius = 50.0f;
imageView.layer.masksToBounds = YES;
imageView.layer.borderColor = [BC_LIGHTBLUE CGColor];
imageView.layer.borderWidth = 2.0;
@sanketfirodiya
sanketfirodiya / gist:bda1914fe55314a8ef74
Created August 14, 2014 13:59
Bottom border to UITextField
- (void)layoutCustomBordersForUITextFields {
for (UIView *view in [self.detailScrollView subviews]) {
if ([view isKindOfClass:[UITextField class]]) {
UITextField *textField = (UITextField *)view;
NSLog(@"textField = %d", textField.tag);
UIView *bottomBorder = [[UIView alloc] initWithFrame:CGRectMake(textField.frame.origin.x, textField.frame.origin.y + textField.frame.size.height - 1, 320, 1)];
bottomBorder.backgroundColor = [UIColor colorWithWhite:0.800 alpha:1.000];
[self.detailScrollView addSubview:bottomBorder];
}
}