Skip to content

Instantly share code, notes, and snippets.

@mthongvanh
Last active December 23, 2015 15:47
Show Gist options
  • Save mthongvanh/dcc11f3ded182357b751 to your computer and use it in GitHub Desktop.
Save mthongvanh/dcc11f3ded182357b751 to your computer and use it in GitHub Desktop.
Xcode Snippets
Debug Log Statement
----------------------
DLog(@"\n<#debugging message#> <#%@#>",<#args#>);
NSString Convenience Method
----------------------------
[NSString stringWithFormat:@"<#%@#>",<#args#>]
Dispatch Asynchronously on Main Queue
-------------------------------------
dispatch_async(dispatch_get_main_queue(), ^{
<#code#>
});
Perform Delegate Check
----------------------
if (<#self.delegate#> && [<#self.delegate#> respondsToSelector:@selector(<#selector#>)])
{
[<#self.delegate#> <#selector#>];
}
else
{
<#NSLog#><#DLog#>(@"<#text#>",<#args#>);
}
Custom Interface Property
----------------------
@property (<#strong#><#weak#><#assign#>, nonatomic) <#IBOutlet#><#Type#> *<#propertyName#>;
Pragma Marks
------------
#pragma mark - <#Main Section#>
#pragma mark <#Sub Section#>
String Constants
----------------
extern NSString *const <#String Constant Variable Name#>;
NSString *const <#String Constant Variable Name#> = @"<#String Value#>";
#pragma mark Web View Delegate
- (void)webViewDidStartLoad:(UIWebView *)webView
{
[self toggleProgressHUDVisiblity:true];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[self toggleProgressHUDVisiblity:false];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
[self toggleProgressHUDVisiblity:false];
}
- (void)toggleProgressHUDVisiblity:(BOOL)visible
{
UIView *hudContainerView = <#targetView#>;
if (hudContainerView)
{
if (visible)
{
[MBProgressHUD showHUDAddedTo:hudContainerView animated:true];
}
else
{
[MBProgressHUD hideAllHUDsForView:hudContainerView animated:true];
}
}
else
{
NSLog(@"%s\n[%s]: Line %i] %@",__FILE__,__PRETTY_FUNCTION__,__LINE__,
@"no feedback container found");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment