1. BOOL
Как не надо делать:
if (dbItem.isFavorite.boolValue == YES) { //... }
return boolvalue ? YES : NO;
boolValue = (x.someproperty) ? YES : NO;
Как надо делать:
if (dbItem.isFavorite.boolValue) {//...}
return boolvalue;
boolValue = (x.someproperty);
2. nil
Как не надо делать:
if(item == nil)
или
return result ? result : nil;
Как надо делать:
if (item)
return result;
3. Основные плагины Alcatraz, которые не стоит не использовать
xAlign
Without:
- (void)cleanUp {
_userId = nil;
_accessToken = nil;
_favoriteListId = nil;
_registerCredential = nil;
}
With:
- (void)cleanUp {
_userId = nil;
_accessToken = nil;
_favoriteListId = nil;
_registerCredential = nil;
}
But:
case StatusTypeInvisible: {
NSDate *date = [NSDate dateWithTimeIntervalSince1970:userStatus.lastConnection.doubleValue / 1000];
if (date.isToday) {
self.dateFormatter.timeStyle = NSDateFormatterShortStyle;
self.dateFormatter.dateStyle = NSDateFormatterNoStyle;
} else {
self.dateFormatter.timeStyle = NSDateFormatterShortStyle;
self.dateFormatter.dateStyle = NSDateFormatterShortStyle;
}
NSString *dateString = [self.dateFormatter stringFromDate:date];
statusString = [NSString stringWithFormat:@"%@ %@",NSLocalizedString(@"USER_STATUS_OFFLINE_OR_INVISIBLE", nil), dateString];
break;
}
MLAutoReplace
@s/ -> @property (nonatomic, strong) <#custom#>
@a/ -> @property (nonatomic, assign) <#custom#>
@w/ -> @property (nonatomic, weak) <#custom#>
+ some extra
FuzzyAutocomplete
Code more for typing less
IntelliPaste
(.m TCProfileVC)
- (void)updateHeaderView
{
dispatch_async(dispatch_get_main_queue(), ^{
NSString *imageUUID = self.userToDisplay.imageId;
UIImage *placeholderImage = [UIImage imageNamed:@"profile_image_placeholder"];
if (imageUUID)
{
NSURL *url = [NSURL imageDownloadUrlForUUID:imageUUID
downloadImageSize:TCImageDownloadSizeMiddle];
[self.headerView.photoButton sd_setImageWithURL:url
forState:UIControlStateNormal
placeholderImage:placeholderImage];
}
else {
[self.headerView.photoButton setImage:placeholderImage
forState:UIControlStateNormal];
}
self.headerView.nameLabel.text = [self nameForUserToDisplay];
self.headerView.nicknameLabel.text = [NSString stringWithFormat:@"@%@",self.userToDisplay.nickname];
[self.tableView reloadData];
});
}
- (NSString *)nameForUserToDisplay
{
NSString *name;
if (self.userToDisplay.firstName || self.userToDisplay.lastName) {
name = [NSString stringWithFormat:@"%@ %@",
self.userToDisplay.firstName ? self.userToDisplay.firstName : @"",
self.userToDisplay.lastName ? self.userToDisplay.lastName: @""];
return name;
}
return @"";
}
- (void)showFAQ
{
NSURL *url = [NSURL URLWithString:kFAQURLString];
SFSafariViewController *sfvc = [[SFSafariViewController alloc] initWithURL:url];
[self presentViewController:sfvc animated:YES completion:nil];
}
cmd + c -> cmd + ctrl + up -> cmd + shift + v
(.h TCProfileVC)
@interface TCProfileVC : UIViewController
- (void)updateHeaderView;
- (NSString *)nameForUserToDisplay;
- (void)showFAQ;
@end
and vice versa
Auto Importer
BKUserCredentialModel -> select -> ctrl+ cmd+ h #import "BKUserCredentialModel.h"
SCXcodeSwitchExpander
typedef NS_ENUM(NSUInteger, TCProfileSettingsSectionType)
{
TCProfileSettingsSectionTypeNotification,
TCProfileSettingsSectionTypeLinkedAccounts,
TCProfileSettingsSectionTypeCache,
TCProfileSettingsSectionTypeChatBackgroundChange,
TCProfileSettingsSectionTypeBlockedUsers,
TCProfileSettingsSectionTypeCountryCode,
TCProfileSettingsSectionTypeRestore
};
TCProfileSettingsSectionType type = //get type
switch (type) {
case <#constant#>:
<#statements#>
break;
default:
break;
}
->
switch (type) {
case TCProfileSettingsSectionTypeNotification: {
<#statement#>
break;
}
case TCProfileSettingsSectionTypeLinkedAccounts: {
<#statement#>
break;
}
case TCProfileSettingsSectionTypeCache: {
<#statement#>
break;
}
case TCProfileSettingsSectionTypeChatBackgroundChange: {
<#statement#>
break;
}
case TCProfileSettingsSectionTypeBlockedUsers: {
<#statement#>
break;
}
case TCProfileSettingsSectionTypeCountryCode: {
<#statement#>
break;
}
case TCProfileSettingsSectionTypeRestore: {
<#statement#>
break;
}
}