Skip to content

Instantly share code, notes, and snippets.

View AdityaDeshmane's full-sized avatar

Aditya Deshmane AdityaDeshmane

View GitHub Profile
@AdityaDeshmane
AdityaDeshmane / iOS : NSCondition Lock Example
Last active January 14, 2025 13:11
iOS : NSCondition Lock Example
-(sqlite3 *) getConnection
{
@try
{
[connMutex lock];
while (bInUse == YES)
{
[connMutex wait];
}
@AdityaDeshmane
AdityaDeshmane / iOS : UIBarButtonItem font and color
Created October 5, 2015 17:01
iOS : UIBarButtonItem font and color
NSDictionary *navbarItemTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName,
[UIFont fontWithName:FONT_NAME_NAVIGATION_BAR size:15],NSFontAttributeName,nil];
[[UIBarButtonItem appearance] setTitleTextAttributes:navbarItemTextAttributes forState:UIControlStateNormal];
@AdityaDeshmane
AdityaDeshmane / iOS : Singleton Class
Last active September 20, 2015 22:10
iOS : Singleton Class
static DataManager* dataManager = nil ;
#pragma mark - Singlton instance creation
+(void)initialize
{
if (!dataManager)
{
dataManager = [[DataManager alloc] init] ;
}
}
@AdityaDeshmane
AdityaDeshmane / iOS : Custom Logs
Created September 20, 2015 21:44
iOS : Custom Logs
#ifdef DEBUG
#define DebugLog(fmt, ...) NSLog((@" < File:%@, Function:%s, Line:%d > :: " fmt),[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DebugLog(...)
#endif
@AdityaDeshmane
AdityaDeshmane / iOS : Localisation Command
Last active October 9, 2016 12:59
iOS : Localisation Command
//Fetches all localisable strings and puts them in .string file, should be executed in top level directory for project
find . -name \*.m -o -name \*.h | xargs genstrings -o en.lproj
@AdityaDeshmane
AdityaDeshmane / iOS : UINavigationController title text Colour & Font
Created September 19, 2015 21:54
iOS : UINavigationController title text Colour & Font
NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName,
[UIFont fontWithName:@"Avenir-Light" size:18],NSFontAttributeName,nil];
self.navigationBar.titleTextAttributes = navbarTitleTextAttributes;
@AdityaDeshmane
AdityaDeshmane / iOS : Subview Leading, Trailing, Top, Bottom Margin Constraint Visual format
Last active October 7, 2016 08:49
iOS : Subview Leading, Trailing, Top, Bottom Margin Constraint Visual format
//Objective C
[self.view addSubview:_viewControllerToAdd.view];
_viewControllerToAdd.view.translatesAutoresizingMaskIntoConstraints = NO;
UIView *subview = _viewControllerToAdd.view;
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[subview]-0-|"
options:0
@AdityaDeshmane
AdityaDeshmane / iOS : UINavigationbar button, font and text color
Last active September 19, 2015 21:57
iOS : UINavigationbar button, font and text color
UIBarButtonItem *barButtonItemCart = [[UIBarButtonItem alloc] initWithTitle:@"Cart"
style:UIBarButtonItemStylePlain
target:self
action:@selector(buttonCartPressed:)];
NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName,
[UIFont fontWithName:@"Avenir-Light" size:16],NSFontAttributeName,nil];
[barButtonItemCart setTitleTextAttributes:navbarTitleTextAttributes forState:UIControlStateNormal];
@AdityaDeshmane
AdityaDeshmane / iOS : UITableView Set Reset Separator Margins
Last active September 17, 2015 13:03
iOS : UITableView Set / Reset Separator Margins
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Remove seperator inset
if ([cell respondsToSelector:@selector(setSeparatorInset:)])
{
[cell setSeparatorInset:UIEdgeInsetsZero];
}
// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)])