-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateViewController.m
More file actions
executable file
·93 lines (57 loc) · 2.45 KB
/
UpdateViewController.m
File metadata and controls
executable file
·93 lines (57 loc) · 2.45 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// UpdateViewController.m
// TypingGame
//
// Created by Jacopo Volpin on 22/05/10.
// Copyright 2010 UniPD. All rights reserved.
//
#import "UpdateViewController.h"
#import "TypingGameAppDelegate.h"
@implementation UpdateViewController
@synthesize updateButton,loading,cVersion;
-(IBAction)updateNow: (UIButton *)sender{
TypingGameAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSURL *url = [NSURL URLWithString:@"http://typinggameiphone.altervista.org/easy.txt"];
appDelegate.wordsEasyURL= [NSString stringWithContentsOfURL:url];
url = [NSURL URLWithString:@"http://typinggameiphone.altervista.org/medium.txt"];
appDelegate.wordsMediumURL= [NSString stringWithContentsOfURL:url];
url = [NSURL URLWithString:@"http://typinggameiphone.altervista.org/hard.txt"];
appDelegate.wordsHardURL= [NSString stringWithContentsOfURL:url];
if (appDelegate.wordsEasyURL!=nil || appDelegate.wordsMediumURL!=nil || appDelegate.wordsHardURL!=nil) {
appDelegate.start=@"YES";
[appDelegate.pref setObject:appDelegate.start forKey:@"start"];
[appDelegate.pref setObject:appDelegate.wordsEasyURL forKey:@"wordsEasyURL"];
[appDelegate.pref setObject:appDelegate.wordsMediumURL forKey:@"wordsMediumURL"];
[appDelegate.pref setObject:appDelegate.wordsHardURL forKey:@"wordsHardURL"];
NSURL *url = [NSURL URLWithString:@"http://typinggameiphone.altervista.org/vers.txt"];
NSString *currentVersion = [NSString stringWithContentsOfURL:url];
appDelegate.version = currentVersion;
[appDelegate.pref setObject:appDelegate.version forKey:@"version"];
[appDelegate displayView:3];
}
else{
NSString *msg = [NSString stringWithFormat:@"No internet connection found!" ];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:msg
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
-(void)viewDidLoad{
TypingGameAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
cVersion.text = [appDelegate.pref objectForKey:@"version"];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end