This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSDate+YGUtilities.m | |
// YGUtilities (https://github.com/YGeorge/YGUtilities) | |
// | |
// Created by George on 26.02.16. | |
// Copyright (c) 2016 George Ymydykov. All rights reserved. | |
// | |
#import "UIView+YGUtilities.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Choose 'login' and 'Keys' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { | |
if (textField == self.percentTextField) { | |
NSString *text = textField.text; | |
if ([string length] == 0 && range.length > 0) { //if delete last symbol | |
if (text.length > 0) { | |
text = [text substringToIndex:[text length] - 2]; | |
textField.text = text.length > 0 ? [NSString stringWithFormat:@"%@%%",text] : @""; | |
} | |
} else { | |
text = [text stringByReplacingCharactersInRange:range withString:string]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)deleteDocumentsForFiles:(NSArray *)files forAccount:(NSString *)accountID success:(void (^)())success failure:(void (^)(NSError *error))failure { | |
__block NSInteger successDeleting = 0; | |
__block NSInteger failureDeleting = 0; | |
dispatch_group_t deleteDocumentGroup = dispatch_group_create(); | |
for (YGFile *file in files) { | |
dispatch_group_enter(deleteDocumentGroup); | |
[YGFileService deleteDocument:file.documentID forAccount:accountID success:^{ | |
DDLogVerbose(@"Delete document %@ success", file.documentID); | |
successDeleting++; | |
DDLogVerbose(@"successDeleting %d", successDeleting); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[sources removeObjectsWithPredicate:^BOOL(id obj){ | |
LCFTSource *source = (LCFTSource *)obj; | |
return [self.hiddenSourceIDs containsObject:source.sourceID]; | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)keyboardWillShow:(NSNotification *)notification { | |
CGRect keyboardFrame = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue]; | |
self.textViewBottomConstraint.constant = keyboardFrame.size.height - self.tabBarController.tabBar.frame.size.height; | |
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap:)]; | |
[self.view addGestureRecognizer:singleTap]; | |
[UIView animateWithDuration:[notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] | |
delay:0 | |
options:(UIViewAnimationOptions) [[notification userInfo][UIKeyboardAnimationCurveUserInfoKey] integerValue] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableArray *resultArray = [NSMutableArray new]; | |
NSMutableOrderedSet *orderedDates = [NSMutableOrderedSet new]; | |
for (LCFeed *feed in feeds) { | |
[orderedDates addObject:feed.createdDateString]; | |
} | |
for (NSString *name in orderedDates) { | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"createdDateString = %@", name]; | |
NSArray *groupOfFeeds = [feeds filteredArrayUsingPredicate:predicate]; | |
[resultArray addObject:groupOfFeeds]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIImage+YGSize.h | |
// | |
#import <Foundation/Foundation.h> | |
@interface UIImage (YGSize) | |
+ (UIImage *)sizedImageWithName:(NSString *)name; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// didFinishLaunchingWithOptions or viewDidLoad: | |
locationManager = [[CLLocationManager alloc] init]; | |
locationManager.delegate = self; | |
locationManager.desiredAccuracy = kCLLocationAccuracyBest; | |
CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; | |
NSLog(@"authorizationStatus: %d", status); | |
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Представьте, что наш объект — это собака. Собака хочет «убежать» (освободить память). | |
Сильный указатель — это поводок с ошейником. Пока поводок прицеплен к ошейнику, собака не убежит. | |
Если 5 человек прицепят 5 поводков к одному ошейнику (5 указателей на 1 объект) — собака не убежит до тех пор, | |
пока не отцепят все 5 поводков. | |
А слабые указатели — это дети, которые тычут пальцем на собаку и кричат: «Ух ты, собака!» | |
Пока собака на поводке, они могут тыкать («указывать на объект») сколько угодно. | |
Но если отсоединить все поводки, то собака убежит, независимо от того, сколько детей тычут в неё пальцем. |
NewerOlder