Skip to content

Instantly share code, notes, and snippets.

git log --pretty=oneline --abbrev-commit --since='yesterday' --author='Eliasz Sawicki'
git log --pretty=oneline --abbrev-commit --since='yesterday' --author='Eliasz Sawicki' | mail -s "Update" "eliasz.sawicki@gmail.com"
@interface Task : NSObject <NSCoding>
@property (nonatomic, strong) NSString *name;
- (instancetype)initWithName:(NSString *)name;
@end
@implementation Task
- (instancetype)initWithName:(NSString *)name {
self = [super init];
if (self) {
self.name = name;
}
return self;
}
- (void)saveTasks {
NSMutableArray *tasksToSave = [NSMutableArray new];
for (NSInteger i = 0 ; i < 5; i ++) {
NSString *taskName = [NSString stringWithFormat:@"%d", arc4random_uniform(50)];
Task *task = [[Task alloc] initWithName:taskName];
[tasksToSave addObject:task];
}
NSString *path = @"~/Documents/";
path = [path stringByAppendingString:@"FILE_NAME"];
- (void)loadTasks {
NSString *path = @"~/Documents/";
path = [path stringByAppendingString:@"FILE_NAME"];
path = [path stringByExpandingTildeInPath];
NSMutableDictionary *rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
NSArray *tasks = rootObject[@"myTasks"];
for (NSInteger i = 0; i < tasks.count; i++) {
@protocol NSCoding
- (void)encodeWithCoder:(NSCoder *)aCoder;
- (id)initWithCoder:(NSCoder *)aDecoder; // NS_DESIGNATED_INITIALIZER
@end
xcrun simctl list | grep "Booted"
@Eluss
Eluss / GainAccessToCalendar.m
Last active August 29, 2015 14:26
Gaining access to calendar in your app
[[EKEventStore new] requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"Access to calendar granted");
} else {
NSLog(@"No access to calendar");
}
}];
@Eluss
Eluss / CalendarList.m
Created July 31, 2015 09:13
Getting calendars list from your calendar
NSArray *calendars = [[EKEventStore new] calendarsForEntityType:EKEntityTypeEvent];