This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathGuideLib.m
44 lines (37 loc) · 1.47 KB
/
GuideLib.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// GuideLib.m
// iFixit
//
// Created by Stefan Ayala on 1/27/14.
//
//
#import "GuideLib.h"
#import "GuideBookmarks.h"
#import "GuideViewController.h"
#import "iFixitAppDelegate.h"
#import "Reachability.h"
@implementation GuideLib
+(void)loadAndPresentGuideForGuideid:(NSNumber*)iGuideid {
Guide *offlineGuide = [[GuideBookmarks sharedBookmarks] guideForGuideid:iGuideid];
GuideViewController *vc;
iFixitAppDelegate *appDelegate = (iFixitAppDelegate*)[UIApplication sharedApplication].delegate;
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus internetStatus = [reachability currentReachabilityStatus];
// Check to see if we have an offline guide first and load up the viewcontroller with it
if (offlineGuide) {
vc = [[GuideViewController alloc] initWithGuide:offlineGuide];
vc.offlineGuide = YES;
// No offline guide? Just use the guideid and retrieve info from API
} else if (!internetStatus == NotReachable) {
vc = [[GuideViewController alloc] initWithGuideid:iGuideid];
} else {
// No internet access or guides, let's display a connection alert and bail
[iFixitAPI displayConnectionErrorAlert];
return;
}
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];
[appDelegate.window.rootViewController presentModalViewController:nc animated:YES];
[vc release];
[nc release];
}
@end