Skip to content

A collection of Xcode snippets that I created to speed up my coding process.

License

Notifications You must be signed in to change notification settings

eddieespinal/XCodeSnippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XCodeSnippets

##Weak Self

csWeakSelf

__weak typeof(self)weakSelf = self;

##Singleton

csSingleton

+ (instancetype)shared<#name#> {
    static <#class#> *_shared<#name#> = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _shared<#name#> = <#initializer#>;
    });
    
    return _shared<#name#>;
}

##Log String

csLogString

NSLog(@"%@", <#string#>);

##Log Pretty Function

csLogFunction

NSLog(@"%s", __PRETTY_FUNCTION__);

##Log Call Stack Symbols

csLogCallStackSymbols

NSLog(@"Call Stack: %@", [NSThread callStackSymbols]);

##Dispatch Async

csDispatchAsync

dispatch_async(dispatch_get_global_queue(<#dispatch_queue_priority_t priority#>, <#unsigned long flags#>), ^(void) {
    <#code#>
    
    dispatch_async(dispatch_get_main_queue(), ^(void) {
        <#code#>
    });
});

##ARC Dealloc

csDealloc

- (void)dealloc
{
    NSLog(@"%s", __PRETTY_FUNCTION__);
}

##NSNotifications Remove Observer

csRemoveObserver

[[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:<#notification name#>;
                                                  object:nil];

##Log Boolean Value

cslogBooleanValue

NSLog(@"%@", (<#Boolean Variable#>) ? @"YES" : @"NO");

##iOS7 Attributed String

csAttributedString

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:<#label.text#>];
            NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
            [paragraphStyle setLineSpacing:<#4.0#>];
            [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [<#label.text#> length])];
            <#label#>.attributedText = attributedString;
            [detailLabel sizeToFit];

##Static Constant NSString

csStaticConstantString

static NSString * const <#kContantName#> = @"<#value#>";

About

A collection of Xcode snippets that I created to speed up my coding process.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages