Open judaco opened 7 years ago
//
// ViewController.m
// Files
//
// Created by hackeru on 07/06/2017.
// Copyright © 2017 juda. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSArray<NSURL*> * urls = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSSystemDomainMask];
//NSCachesDirectory
if (urls.count == 1) {
NSLog(@"%@", urls[0]);
}else{
NSLog(@"error");
}
NSString * temp = NSTemporaryDirectory();
NSLog(@"temp: %@", temp);
NSString * someText = @"Juda sta qui";
NSString * destination = [NSString stringWithFormat:@"%@MyFile1.txt", temp];
// NSError * error;
// [someText writeToFile:destination atomically:YES encoding:NSUTF8StringEncoding error:&error];
//
// NSString * someTextFromFile = [NSString stringWithContentsOfFile:destination encoding:NSUTF8StringEncoding error:&error];
// NSLog(@"%@", someTextFromFile);
// NSArray * names = [NSArray arrayWithObjects:@"juda", @"shalev", nil];
// [names writeToFile:destination atomically:YES];
NSArray<NSString*> * names = [NSArray arrayWithContentsOfFile:destination];
if (names != nil) {
NSLog(@"not nil");
}else{
NSLog(@"is nil");
}
// for (NSString * name in names) {
// NSLog(@"%@", name);
// }
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// ViewController.m
// NSDate
//
// Created by hackeru on 07/06/2017.
// Copyright © 2017 juda. All rights reserved.
//
#import "ViewController.h"
#import <EventKit/EventKit.h>
#import <EventKitUI/EventKitUI.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//Lesson for NSDate
NSDate * date = [[NSCalendar currentCalendar] dateWithEra:1 year:2017 month:6 day:7 hour:20 minute:38 second:0 nanosecond:0];
NSDate * now = [NSDate date];
NSLog(@"%@", [now description]);
NSDate * newDate = [[NSCalendar currentCalendar] dateByAddingUnit:NSCalendarUnitHour value:7 toDate:now options:NSCalendarMatchNextTime];
NSLog(@"%@", [newDate description]);
NSDateComponents * components = [[NSCalendar currentCalendar] componentsInTimeZone:[NSTimeZone localTimeZone] fromDate:now];
NSLog(@"%lu", components.hour);
NSDateComponents * compo = [[NSDateComponents alloc] init];
compo.year = 2017;
compo.month = 6;
compo.day = 7;
compo.hour = 20;
compo.minute = 48;
NSDate * dateFromCompo = [[NSCalendar currentCalendar] dateFromComponents:compo];
NSLog(@"%@", [dateFromCompo description]);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// ViewController.m
// Calendar
//
// Created by hackeru on 07/06/2017.
// Copyright © 2017 juda. All rights reserved.
//
#import "ViewController.h"
#import <EventKit/EventKit.h>
#import <EventKitUI/EventKitUI.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
EKEventStore * eventStore = [[EKEventStore alloc] init];
EKAuthorizationStatus status = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent];//static method
switch (status) {
case EKAuthorizationStatusAuthorized:
break;
case EKAuthorizationStatusRestricted:
NSLog(@"access restricted");
break;
case EKAuthorizationStatusDenied:
NSLog(@"access denied");
break;
case EKAuthorizationStatusNotDetermined:
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
<#statements#>
}
}];
break;
default:
break;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
to complete