Skip to content

Instantly share code, notes, and snippets.

View etolstoy's full-sized avatar
🥦

Egor Tolstoy etolstoy

🥦
View GitHub Profile
@etolstoy
etolstoy / gist:8621330
Created January 25, 2014 18:44
2.23 App Store Review Guidelines
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
@etolstoy
etolstoy / linechart-setup
Created January 25, 2014 19:04
[ios-linechart] Setup
LineChartData *d = [LineChartData new];
d.xMin = 1;
d.xMax = [daysStatistics count];
d.title = @"The title for the legend";
d.color = [UIColor colorWithRed:0/255.0f green:179/255.0f blue:219/255.0f alpha:1.0f];
d.itemCount = [daysStatistics count];
@etolstoy
etolstoy / linechart-setup2
Created January 25, 2014 19:05
[ios-linechart] Additional Setup
NSMutableArray *days = [NSMutableArray new];
NSMutableArray *verbs = [NSMutableArray new];
for(NSUInteger i = 0; i < d.itemCount; ++i)
{
PVPDayStat *item = [[PVPDayStat alloc] init];
item = [daysStatistics objectAtIndex:i];
[days addObject:@([item.day intValue])];
[verbs addObject:@([item.verbs intValue])];
}
@etolstoy
etolstoy / linechart-usage
Created January 25, 2014 19:06
[ios-linechart] Usage
_chartView = [[LineChartView alloc] initWithFrame:CGRectMake(0, 210, 300, 220)];
if (d.itemCount <= 5)
_chartView.drawsDataPoints = YES;
else
_chartView.drawsDataPoints = NO;
_chartView.yMin = 0;
_chartView.yMax = [PVPVerbData getOverallVerbsQuantity];
_chartView.ySteps = @[@"0",
[NSString stringWithFormat:@"%.f", _chartView.yMax / 8],
[NSString stringWithFormat:@"%.f", _chartView.yMax / 4],
@etolstoy
etolstoy / dynss-1
Created January 26, 2014 11:52
Dynamic String Search
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
_data = [SBHotspotData findHotspot:searchText];
[self.searchResultsTableView reloadData];
}
@etolstoy
etolstoy / dynss-2
Created January 26, 2014 11:54
Dynamic String Search - 2
+ (NSArray *) findHotspot: (NSString *)partOfTitle
{
SBHotspotData *item;
NSMutableArray *result = [NSMutableArray array];
NSString *path = [self getDatabasePath];
FMDatabase *database;
database = [FMDatabase databaseWithPath:path];
[database open];
NSString *query = [NSString stringWithFormat:@"select * from hotspots where TitleLow like '%%%@%%'", [partOfTitle lowercaseString]];
FMResultSet *results = [database executeQuery:query];
@etolstoy
etolstoy / dynss-3
Created January 26, 2014 11:55
Dynamic String Search - 3
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:item.hotspotTitle];
NSRange range = [item.hotspotTitle rangeOfString:_searchHotspotBar.text];
[attributedString addAttribute:NSBackgroundColorAttributeName value:[UIColor colorWithRed:216/255.0f green:87/255.0f blue:23/255.0f alpha:1.0f] range:range];
cell.cellLabel.attributedText = attributedString;
@etolstoy
etolstoy / fma
Last active August 29, 2015 13:55
Footer Menu Animation
- (void)showMenu
{
CALayer* layer = _menuButtonImageView.layer;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0 * M_PI];
animation.toValue = [NSNumber numberWithFloat:1.0 * M_PI];
animation.duration = 0.3;
animation.cumulative = YES;
@etolstoy
etolstoy / CEViewController.m
Created March 2, 2014 17:27
customcontrol-1
#import "CERangeSlider.h"
@etolstoy
etolstoy / CEViewController.m
Created March 2, 2014 17:28
customcontrol-2
@implementation CEViewController
{
CERangeSlider* _rangeSlider;
}