Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // BsuirHelperVCSchedule.m
- // BSUIR Helper
- //
- // Created by Alex Oshevnev on 7/16/12.
- // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
- //
- #import <QuartzCore/QuartzCore.h>
- #import "BsuirHelperVCSchedule.h"
- #import "SystemConfiguration/SystemConfiguration.h"
- #import "TFHpple.h"
- @interface BsuirHelperVCSchedule ()
- @end
- @implementation BsuirHelperVCSchedule
- @synthesize TextLabelWeek;
- @synthesize refreshProtocol;
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)viewDidLoad
- {
- // Divarication
- if (![[NSUserDefaults standardUserDefaults]valueForKey:@"groupValue"]) {
- [self performSegueWithIdentifier: @"StoryboardSegueSecondLaunch" sender: self];
- }
- else {
- // Change TextLaberWeek
- SCNetworkReachabilityFlags flags;
- BOOL receivedFlags;
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(CFAllocatorGetDefault(), [@"google.com" UTF8String]);
- receivedFlags = SCNetworkReachabilityGetFlags(reachability, &flags);
- CFRelease(reachability);
- if ((receivedFlags && (flags != 0)) && ![[[NSUserDefaults standardUserDefaults] valueForKey:@"numberWeek"] objectForKey:@"numberWeek"]) {
- [refreshProtocol getNumberWeek];
- }
- else {
- [refreshProtocol recalculateNumberWeek];
- }
- TextLabelWeek.text = [[[NSUserDefaults standardUserDefaults] valueForKey:@"numberWeek"] objectForKey:@"numberWeek"];
- }
- self.refreshProtocol = [[BsuirHelperRefreshDelegate new] autorelease];
- self.refreshProtocol.delegate = self;
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- }
- - (void)viewDidUnload
- {
- [self setTextLabelWeek:nil];
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- {
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
- }
- // Table
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return [[self.refreshProtocol returnDataForTable] count];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- NSArray *curent = [self curent:section];
- return [curent count];
- }
- - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
- return [[[self.refreshProtocol returnDataForTable] allKeys] objectAtIndex:section];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
- reuseIdentifier:CellIdentifier] autorelease];
- }
- NSArray *curent = [self curent:indexPath.section];
- cell.textLabel.text = [curent objectAtIndex:indexPath.row];
- return cell;
- }
- - (NSArray *)curent:(NSInteger)index {
- NSArray *keys = [[self.refreshProtocol returnDataForTable] allKeys];
- NSString *curentKey = [keys objectAtIndex:index];
- NSArray *curent = [[self.refreshProtocol returnDataForTable] objectForKey:curentKey];
- return curent;
- }
- // Buttons
- - (IBAction)BarButtonPageCurlAction:(id)sender {
- [self performSegueWithIdentifier: @"StoryboardSegueSetting" sender: self];
- }
- - (IBAction)BarButtonRefreshAction:(id)sender {
- if ([[[NSUserDefaults standardUserDefaults]valueForKey:@"groupValue"] length] != 6) {
- [self performSegueWithIdentifier: @"StoryboardSegueSetting" sender: self];
- } else {
- SCNetworkReachabilityFlags flags;
- BOOL receivedFlags;
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(CFAllocatorGetDefault(), [@"google.com" UTF8String]);
- receivedFlags = SCNetworkReachabilityGetFlags(reachability, &flags);
- CFRelease(reachability);
- UIAlertView *InternetDown = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_attentionTitle", nil)
- message:NSLocalizedString(@"_internetDownText", nil)
- delegate:self
- cancelButtonTitle:NSLocalizedString(@"_dismiss", nil)
- otherButtonTitles:nil];
- if (receivedFlags && (flags != 0)) {
- [InternetDown release];
- [refreshProtocol writeDB];
- }
- else {
- [InternetDown show];
- [InternetDown release];
- }
- }
- }
- - (void)dealloc {
- [TextLabelWeek release];
- [super dealloc];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement