├── .gitignore
├── CodeSamples
├── Lecture 1-2
│ ├── iosc.02.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── iosc.02
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── LaunchImage.launchimage
│ │ │ │ └── Contents.json
│ │ ├── RSS.h
│ │ ├── RSS.m
│ │ ├── RssChannel.h
│ │ ├── RssChannel.m
│ │ ├── RssItem.h
│ │ ├── RssItem.m
│ │ ├── en.lproj
│ │ │ └── InfoPlist.strings
│ │ ├── iosc.02-Info.plist
│ │ ├── iosc.02-Prefix.pch
│ │ └── main.m
│ └── iosc.02Tests
│ │ ├── en.lproj
│ │ └── InfoPlist.strings
│ │ ├── iosc.02Tests-Info.plist
│ │ └── iosc_02Tests.m
├── Lecture 3
│ ├── iosc.02.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── iosc.02
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── LaunchImage.launchimage
│ │ │ │ └── Contents.json
│ │ ├── RSS.h
│ │ ├── RSS.m
│ │ ├── RssChannel.h
│ │ ├── RssChannel.m
│ │ ├── RssItem.h
│ │ ├── RssItem.m
│ │ ├── RssParser.h
│ │ ├── RssParser.m
│ │ ├── en.lproj
│ │ │ └── InfoPlist.strings
│ │ ├── iosc.02-Info.plist
│ │ ├── iosc.02-Prefix.pch
│ │ ├── main.m
│ │ └── rss.xml
│ └── iosc.02Tests
│ │ ├── en.lproj
│ │ └── InfoPlist.strings
│ │ ├── iosc.02Tests-Info.plist
│ │ └── iosc_02Tests.m
├── Lecture 4
│ ├── iosc.02.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── iosc.02
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── LaunchImage.launchimage
│ │ │ │ └── Contents.json
│ │ ├── RSS.h
│ │ ├── RSS.m
│ │ ├── RssChannel.h
│ │ ├── RssChannel.m
│ │ ├── RssItem.h
│ │ ├── RssItem.m
│ │ ├── RssItemViewController.h
│ │ ├── RssItemViewController.m
│ │ ├── RssItemViewController.xib
│ │ ├── RssParser.h
│ │ ├── RssParser.m
│ │ ├── en.lproj
│ │ │ └── InfoPlist.strings
│ │ ├── iosc.02-Info.plist
│ │ ├── iosc.02-Prefix.pch
│ │ ├── main.m
│ │ └── rss.xml
│ └── iosc.02Tests
│ │ ├── en.lproj
│ │ └── InfoPlist.strings
│ │ ├── iosc.02Tests-Info.plist
│ │ └── iosc_02Tests.m
├── Lecture 5
│ ├── iosc.02.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── iosc.02
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── LaunchImage.launchimage
│ │ │ │ └── Contents.json
│ │ ├── RSS.h
│ │ ├── RSS.m
│ │ ├── RssChannel.h
│ │ ├── RssChannel.m
│ │ ├── RssChannelViewController.h
│ │ ├── RssChannelViewController.m
│ │ ├── RssChannelViewController.xib
│ │ ├── RssItem.h
│ │ ├── RssItem.m
│ │ ├── RssItemViewController.h
│ │ ├── RssItemViewController.m
│ │ ├── RssItemViewController.xib
│ │ ├── RssParser.h
│ │ ├── RssParser.m
│ │ ├── UIImage+Colored.h
│ │ ├── UIImage+Colored.m
│ │ ├── UIImage+Resize.h
│ │ ├── UIImage+Resize.m
│ │ ├── en.lproj
│ │ │ └── InfoPlist.strings
│ │ ├── iosc.02-Info.plist
│ │ ├── iosc.02-Prefix.pch
│ │ ├── main.m
│ │ └── rss.xml
│ └── iosc.02Tests
│ │ ├── en.lproj
│ │ └── InfoPlist.strings
│ │ ├── iosc.02Tests-Info.plist
│ │ └── iosc_02Tests.m
├── Lecture 6 (MapKit)
│ ├── IoscMapKit.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── IoscMapKit
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── CoordinateAnnotation.h
│ │ ├── CoordinateAnnotation.m
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── LaunchImage.launchimage
│ │ │ │ └── Contents.json
│ │ ├── IoscMapKit-Info.plist
│ │ ├── IoscMapKit-Prefix.pch
│ │ ├── MapViewController.h
│ │ ├── MapViewController.m
│ │ ├── MapViewController.xib
│ │ ├── en.lproj
│ │ │ └── InfoPlist.strings
│ │ └── main.m
│ └── IoscMapKitTests
│ │ ├── IoscMapKitTests-Info.plist
│ │ ├── IoscMapKitTests.m
│ │ └── en.lproj
│ │ └── InfoPlist.strings
├── Lecture 6
│ ├── iosc.02.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── iosc.02
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── LaunchImage.launchimage
│ │ │ │ └── Contents.json
│ │ ├── NSString+Stripping.h
│ │ ├── NSString+Stripping.m
│ │ ├── RSS.h
│ │ ├── RSS.m
│ │ ├── RssChannel.h
│ │ ├── RssChannel.m
│ │ ├── RssChannelViewController.h
│ │ ├── RssChannelViewController.m
│ │ ├── RssChannelViewController.xib
│ │ ├── RssItem.h
│ │ ├── RssItem.m
│ │ ├── RssItemCell.h
│ │ ├── RssItemCell.m
│ │ ├── RssItemCell.xib
│ │ ├── RssItemViewController.h
│ │ ├── RssItemViewController.m
│ │ ├── RssItemViewController.xib
│ │ ├── RssParser.h
│ │ ├── RssParser.m
│ │ ├── UIImage+Colored.h
│ │ ├── UIImage+Colored.m
│ │ ├── UIImage+Resize.h
│ │ ├── UIImage+Resize.m
│ │ ├── en.lproj
│ │ │ └── InfoPlist.strings
│ │ ├── iosc.02-Info.plist
│ │ ├── iosc.02-Prefix.pch
│ │ ├── main.m
│ │ └── rss.xml
│ └── iosc.02Tests
│ │ ├── en.lproj
│ │ └── InfoPlist.strings
│ │ ├── iosc.02Tests-Info.plist
│ │ └── iosc_02Tests.m
└── Lecture 7
│ ├── iosc.02.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── iosc.02
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Images.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── LaunchImage.launchimage
│ │ │ └── Contents.json
│ ├── NSString+Stripping.h
│ ├── NSString+Stripping.m
│ ├── RSS.h
│ ├── RSS.m
│ ├── RssChannel.h
│ ├── RssChannel.m
│ ├── RssChannelViewController.h
│ ├── RssChannelViewController.m
│ ├── RssChannelViewController.xib
│ ├── RssItem.h
│ ├── RssItem.m
│ ├── RssItemCell.h
│ ├── RssItemCell.m
│ ├── RssItemCell.xib
│ ├── RssItemViewController.h
│ ├── RssItemViewController.m
│ ├── RssItemViewController.xib
│ ├── RssLoader.h
│ ├── RssLoader.m
│ ├── RssParser.h
│ ├── RssParser.m
│ ├── UIImage+Colored.h
│ ├── UIImage+Colored.m
│ ├── UIImage+Resize.h
│ ├── UIImage+Resize.m
│ ├── en.lproj
│ │ └── InfoPlist.strings
│ ├── iosc.02-Info.plist
│ ├── iosc.02-Prefix.pch
│ ├── main.m
│ └── rss.xml
│ └── iosc.02Tests
│ ├── en.lproj
│ └── InfoPlist.strings
│ ├── iosc.02Tests-Info.plist
│ └── iosc_02Tests.m
├── README.md
├── Snippets
├── lecture.3.m
└── lecture.4.m
├── forecast.xml
├── lectures
├── iOS. Lecture 1.pdf
├── iOS. Lecture 2.pdf
├── iOS. Lecture 3.pdf
├── iOS. Lecture 4.pdf
├── iOS. Lecture 5.pdf
├── iOS. Lecture 6.pdf
├── iOS. Lecture 7.pdf
├── iOS. Lecture 8.pdf
├── iOS. Lecture 8.university.pdf
├── iOS. Lecture 9.pdf
├── iOS. Lecture PS. 1.pdf
├── iOS. Lecture PS. 2.pdf
└── iOS. Lecture PS. 3.pdf
└── rss.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | CodeSamples/*/*.xcodeproj/project.xcworkspace/xcuserdata
2 | CodeSamples/*/*.xcodeproj/xcuserdata
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | #import "RSS.h"
12 |
13 | @implementation AppDelegate
14 |
15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
16 | {
17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
18 | // Override point for customization after application launch.
19 | self.window.backgroundColor = [UIColor whiteColor];
20 | [self.window makeKeyAndVisible];
21 |
22 | RSS* rss = [ RSS sample ];
23 | NSLog( @"%@", [ rss description ] );
24 |
25 |
26 | return YES;
27 | }
28 |
29 | - (void)applicationWillResignActive:(UIApplication *)application
30 | {
31 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
32 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
33 | }
34 |
35 | - (void)applicationDidEnterBackground:(UIApplication *)application
36 | {
37 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
38 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
39 | }
40 |
41 | - (void)applicationWillEnterForeground:(UIApplication *)application
42 | {
43 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
44 | }
45 |
46 | - (void)applicationDidBecomeActive:(UIApplication *)application
47 | {
48 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
49 | }
50 |
51 | - (void)applicationWillTerminate:(UIApplication *)application
52 | {
53 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
54 | }
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "size" : "29x29",
21 | "scale" : "1x"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "size" : "29x29",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "size" : "40x40",
31 | "scale" : "1x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "40x40",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "76x76",
41 | "scale" : "1x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "76x76",
46 | "scale" : "2x"
47 | }
48 | ],
49 | "info" : {
50 | "version" : 1,
51 | "author" : "xcode"
52 | }
53 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/RSS.h:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RSS : NSObject
12 |
13 | @property ( nonatomic, retain ) NSArray* Channels;
14 |
15 | +( RSS* ) sample;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/RSS.m:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RSS.h"
10 | #import "RssChannel.h"
11 |
12 | @implementation RSS
13 | {
14 | NSArray* _channels;
15 | }
16 |
17 | @synthesize Channels = _channels;
18 |
19 | -( id ) init
20 | {
21 | self = [ super init ];
22 |
23 | if ( nil != self )
24 | {
25 | // TODO:
26 | }
27 |
28 | return self;
29 | }
30 |
31 | -( void ) dealloc
32 | {
33 | [ _channels release ];
34 |
35 | [ super dealloc ];
36 | }
37 |
38 | -( NSString* ) description
39 | {
40 | NSMutableString* str = [ NSMutableString string ];
41 |
42 | [ str appendFormat: @"Channels:\n" ];
43 |
44 | for ( RssChannel* ch in _channels )
45 | {
46 | [ str appendFormat: @"%@\n", [ ch description ] ];
47 | }
48 |
49 | return [ NSString stringWithString: str ];
50 | }
51 |
52 | #pragma mark - public routines
53 |
54 | +( RSS* ) sample
55 | {
56 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
57 |
58 | RssChannel* ch = [ RssChannel sampleChannel ];
59 |
60 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
61 |
62 | return rss;
63 | }
64 |
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/RssChannel.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssChannel : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* Link;
15 | @property ( nonatomic, copy ) NSString* Desc;
16 | @property ( nonatomic, retain ) NSArray* Items;
17 |
18 | +( RssChannel* ) sampleChannel;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/RssChannel.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 | #import "RssChannel.h"
11 |
12 | @implementation RssChannel
13 | {
14 | NSString* _title;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSArray* _items;
18 | }
19 |
20 | @synthesize Title = _title;
21 | @synthesize Link = _link;
22 | @synthesize Desc = _desc;
23 | @synthesize Items = _items;
24 |
25 | -( id ) init
26 | {
27 | self = [ super init ];
28 |
29 | if ( nil != self )
30 | {
31 | // TODO:
32 | }
33 |
34 | return self;
35 | }
36 |
37 | -( void ) dealloc
38 | {
39 | [ _title release ];
40 | [ _link release ];
41 | [ _desc release ];
42 | [ _items release ];
43 |
44 | [ super dealloc ];
45 | }
46 |
47 | -( NSString* ) description
48 | {
49 | NSMutableString* str = [ NSMutableString string ];
50 |
51 | [ str appendFormat: @"\tTitle: %@\n", _title ];
52 | [ str appendFormat: @"\tLink: %@\n", _link ];
53 | [ str appendFormat: @"\tDesc: %@\n", _desc ];
54 | [ str appendFormat: @"\tItems:\n" ];
55 |
56 | for ( RssItem* item in _items )
57 | {
58 | [ str appendFormat: @"%@\n", [ item description ] ];
59 | }
60 |
61 | return [ NSString stringWithString: str ];
62 | }
63 |
64 | #pragma mark - public routines
65 |
66 | +( RssChannel* ) sampleChannel
67 | {
68 | RssChannel* ch = [ [ [ RssChannel alloc] init ] autorelease ];
69 |
70 | ch.Title = @"it works!";
71 | ch.Link = @"http://itw66.ru";
72 | ch.Desc = @"it works! / RSS channel";
73 |
74 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
75 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
76 |
77 | RssItem* item = [ [ [ RssItem alloc ] init ] autorelease ];
78 | item.Title = @"Персональный батискаф";
79 | item.GUID = @"http://itw66.ru/blog/interesting_things/743.html";
80 | item.Link = @"http://itw66.ru/blog/interesting_things/743.html";
81 | item.Desc = @" Жак=Ив Кусто, один из создателей акваланга, является одним из самых известных исследователей морей и океанов. Всем хорошо известна «Подводная одиссея команды Кусто». Кроме того, один из его первых цветных подводных фильмов был удостоен Пальмовой Ветви в Каннах в 1956 году. Кусто успел повидать и поведать нам о многом, но несмотря на это морское дно хранит еще много тайн о жизни на Земле. С начала исследований морского дна и во многом благодаря им были сделаны существенные технологические и экологические открытия. Совсем недавно, в 2010 году, в своей речи на событии Mission Blue, организованном TED, океанограф Эдит Виддер (Edith Widder) говорила об исследовании водной части Земли и заметила, что в исследование морских глубин денег вкладывается гораздо меньше, чем например в исследовании космоса, хотя на данный момент всего около 5% океанов исследовано человеком. Она также заметила, что исследования — это сила, которая движет инновациями. Ее призыв услышал дизайнер Эдуардо Гальвани (Eduardo Galvani), который предложил проект персонального батискафа — Manatee, для создания возможности персонального изучения морских глубин.подробности... ";
82 | item.PubDate = [ fmt dateFromString: @"Thu, 03 Jul 2014 12:56:57 +0400" ];
83 | item.Categories = [ NSArray arrayWithObjects: @"батискаф", @"персональный", @"manatee", @"Eduardo Galvani", nil ];
84 |
85 | RssItem* item2 = [ [ [ RssItem alloc ] init ] autorelease ];
86 | item2.Title = @"Новый взгляд на ветряную турбину!";
87 | item2.GUID = @"http://itw66.ru/blog/alternative_energy/742.html";
88 | item2.Link = @"http://itw66.ru/blog/alternative_energy/742.html";
89 | item2.Desc = @"img src=\"http://itw66.ru/uploads/images/00/00/01/2014/06/23/2f7842.jpg\"/> Все мы уже привыкли к традиционным формам ветряков, которые конструкцию свою получили от достаточно древних ветряных мельниц. У них есть как свои плюсы, так и свои минусы. Специалисты из компании Solar Wind Energy Inc. задумались над тем, как решить проблему отсутствия ветра, а заодно и повышения КПД устройства. В итоге они изобрели Solar Wind Downdraft Tower, башню, которая для генерации электричества может создавать свой собственный ветер. Как это может работать? Читайте далее…а вот как... ";
90 | item2.PubDate = [ fmt dateFromString: @"Mon, 23 Jun 2014 21:45:20 +0400" ];
91 | item2.Categories = [ NSArray arrayWithObjects: @"Solar Wind Energy Inc", @"Downdraft Tower", @"башня-ветряк", nil ];
92 |
93 | ch.Items = [ NSArray arrayWithObjects: item, item2, nil ];
94 |
95 | return ch;
96 | }
97 |
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/RssItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssItem : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* GUID;
15 | @property ( nonatomic, copy ) NSString* Link;
16 | @property ( nonatomic, copy ) NSString* Desc;
17 | @property ( nonatomic, retain ) NSDate* PubDate;
18 | @property ( nonatomic, retain ) NSArray* Categories;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/RssItem.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 |
11 | @implementation RssItem
12 | {
13 | NSString* _title;
14 | NSString* _guid;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSDate* _pubDate;
18 | NSArray* _categories;
19 | }
20 |
21 | @synthesize Title = _title;
22 | @synthesize GUID = _guid;
23 | @synthesize Link = _link;
24 | @synthesize Desc = _desc;
25 | @synthesize PubDate = _pubDate;
26 | @synthesize Categories = _categories;
27 |
28 | -( id ) init
29 | {
30 | self = [ super init ];
31 |
32 | if ( nil != self )
33 | {
34 | // TODO:
35 | }
36 |
37 | return self;
38 | }
39 |
40 | -( void ) dealloc
41 | {
42 | [ _title release ];
43 | [ _guid release ];
44 | [ _link release ];
45 | [ _desc release ];
46 | [ _pubDate release ];
47 | [ _categories release ];
48 |
49 | [ super dealloc ];
50 | }
51 |
52 | -( NSString* ) description
53 | {
54 | NSMutableString* str = [ NSMutableString string ];
55 |
56 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
57 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
58 |
59 | [ str appendFormat: @"\t\tTitle: %@\n", _title ];
60 | [ str appendFormat: @"\t\tGUID: %@\n", _guid ];
61 | [ str appendFormat: @"\t\tLink: %@\n", _link ];
62 | [ str appendFormat: @"\t\tDesc: %@\n", _desc ];
63 | [ str appendFormat: @"\t\tPubDate: %@\n", [ fmt stringFromDate: _pubDate ] ];
64 | [ str appendFormat: @"\t\tCategories: " ];
65 |
66 | for ( NSString* cat in _categories )
67 | {
68 | [ str appendFormat: @"%@, ", cat ];
69 | }
70 | [ str appendFormat: @"\n" ];
71 |
72 | return [ NSString stringWithString: str ];
73 | }
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/iosc.02-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/iosc.02-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_3_0
10 | #warning "This project uses features only available in iOS SDK 3.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02Tests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02Tests/iosc.02Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 1-2/iosc.02Tests/iosc_02Tests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iosc_02Tests.m
3 | // iosc.02Tests
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iosc_02Tests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iosc_02Tests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | #import "RSS.h"
12 | #import "RssParser.h"
13 |
14 | @interface AppDelegate ( ) < RssLoadingProtocol >
15 |
16 | -( void ) rssLoaded: ( RSS* )rss;
17 |
18 | @end
19 |
20 | @implementation AppDelegate
21 |
22 | -( void ) rssLoaded: ( RSS* )rss
23 | {
24 | NSLog( @"RSS loaded (TS): %@", [ rss description ] );
25 | }
26 |
27 | -( void ) didSucceededLoadRSS: ( RSS* )rss
28 | {
29 | NSLog( @"RSS loaded (Prot): %@", [ rss description ] );
30 | }
31 |
32 | -( void ) didRSSLoadFailed: ( NSError* )error
33 | {
34 | NSLog( @"RSS load failed: %@ [ %@ ] ", error, [ error userInfo ] );
35 | }
36 |
37 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
38 | {
39 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
40 | // Override point for customization after application launch.
41 | self.window.backgroundColor = [UIColor whiteColor];
42 | [self.window makeKeyAndVisible];
43 |
44 | /*
45 | RSS* rss = [ RSS sample ];
46 | NSLog( @"%@", [ rss description ] );
47 | */
48 |
49 | [ RSS loadRssFromFile: @"file.sample.txt" target: self selector: @selector( rssLoaded: ) ];
50 | [ RSS loadRssFromFile: [ [ NSBundle mainBundle ] pathForResource: @"rss" ofType: @"xml" ] thenCallback: self ];
51 |
52 | return YES;
53 | }
54 |
55 | - (void)applicationWillResignActive:(UIApplication *)application
56 | {
57 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
58 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
59 | }
60 |
61 | - (void)applicationDidEnterBackground:(UIApplication *)application
62 | {
63 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
64 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
65 | }
66 |
67 | - (void)applicationWillEnterForeground:(UIApplication *)application
68 | {
69 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
70 | }
71 |
72 | - (void)applicationDidBecomeActive:(UIApplication *)application
73 | {
74 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
75 | }
76 |
77 | - (void)applicationWillTerminate:(UIApplication *)application
78 | {
79 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
80 | }
81 |
82 | @end
83 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "size" : "29x29",
21 | "scale" : "1x"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "size" : "29x29",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "size" : "40x40",
31 | "scale" : "1x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "40x40",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "76x76",
41 | "scale" : "1x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "76x76",
46 | "scale" : "2x"
47 | }
48 | ],
49 | "info" : {
50 | "version" : 1,
51 | "author" : "xcode"
52 | }
53 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/RSS.h:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RSS;
12 |
13 | @protocol RssLoadingProtocol
14 |
15 | -( void ) didSucceededLoadRSS: ( RSS* )rss;
16 | -( void ) didRSSLoadFailed: ( NSError* )error;
17 |
18 | @end
19 |
20 | @interface RSS : NSObject
21 |
22 | @property ( nonatomic, retain ) NSArray* Channels;
23 |
24 | +( RSS* ) sample;
25 |
26 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector;
27 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/RSS.m:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RSS.h"
10 | #import "RssChannel.h"
11 | #import "RssItem.h"
12 |
13 | #import "RssParser.h"
14 |
15 | @implementation RSS
16 | {
17 | NSArray* _channels;
18 | }
19 |
20 | @synthesize Channels = _channels;
21 |
22 | -( id ) init
23 | {
24 | self = [ super init ];
25 |
26 | if ( nil != self )
27 | {
28 | // TODO:
29 | }
30 |
31 | return self;
32 | }
33 |
34 | -( void ) dealloc
35 | {
36 | [ _channels release ];
37 |
38 | [ super dealloc ];
39 | }
40 |
41 | -( NSString* ) description
42 | {
43 | NSMutableString* str = [ NSMutableString string ];
44 |
45 | [ str appendFormat: @"Channels:\n" ];
46 |
47 | for ( RssChannel* ch in _channels )
48 | {
49 | [ str appendFormat: @"%@\n", [ ch description ] ];
50 | }
51 |
52 | return [ NSString stringWithString: str ];
53 | }
54 |
55 | #pragma mark - public routines
56 |
57 | +( RSS* ) sample
58 | {
59 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
60 |
61 | RssChannel* ch = [ RssChannel sampleChannel ];
62 |
63 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
64 |
65 | return rss;
66 | }
67 |
68 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector
69 | {
70 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
71 | RssChannel* ch = [ RssChannel sampleChannel ];
72 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
73 |
74 | if ( [ target respondsToSelector: selector ] )
75 | [ target performSelector: selector withObject: rss ];
76 | }
77 |
78 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback
79 | {
80 | RssParser* parser = [ [ [ RssParser alloc ] init ] autorelease ];
81 | RSS* rss = [ parser parseRssFeedFromFile: fileName ];
82 |
83 | if ( nil != callback )
84 | [ callback didSucceededLoadRSS: rss ];
85 | }
86 |
87 |
88 | @end
89 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/RssChannel.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssChannel : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* Link;
15 | @property ( nonatomic, copy ) NSString* Desc;
16 | @property ( nonatomic, retain ) NSArray* Items;
17 |
18 | +( RssChannel* ) sampleChannel;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/RssChannel.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 | #import "RssChannel.h"
11 |
12 | @implementation RssChannel
13 | {
14 | NSString* _title;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSArray* _items;
18 | }
19 |
20 | @synthesize Title = _title;
21 | @synthesize Link = _link;
22 | @synthesize Desc = _desc;
23 | @synthesize Items = _items;
24 |
25 | -( id ) init
26 | {
27 | self = [ super init ];
28 |
29 | if ( nil != self )
30 | {
31 | // TODO:
32 | }
33 |
34 | return self;
35 | }
36 |
37 | -( void ) dealloc
38 | {
39 | [ _title release ];
40 | [ _link release ];
41 | [ _desc release ];
42 | [ _items release ];
43 |
44 | [ super dealloc ];
45 | }
46 |
47 | -( NSString* ) description
48 | {
49 | NSMutableString* str = [ NSMutableString string ];
50 |
51 | [ str appendFormat: @"\tTitle: %@\n", _title ];
52 | [ str appendFormat: @"\tLink: %@\n", _link ];
53 | [ str appendFormat: @"\tDesc: %@\n", _desc ];
54 | [ str appendFormat: @"\tItems:\n" ];
55 |
56 | for ( RssItem* item in _items )
57 | {
58 | [ str appendFormat: @"%@\n", [ item description ] ];
59 | }
60 |
61 | return [ NSString stringWithString: str ];
62 | }
63 |
64 | #pragma mark - public routines
65 |
66 | +( RssChannel* ) sampleChannel
67 | {
68 | RssChannel* ch = [ [ [ RssChannel alloc] init ] autorelease ];
69 |
70 | ch.Title = @"it works!";
71 | ch.Link = @"http://itw66.ru";
72 | ch.Desc = @"it works! / RSS channel";
73 |
74 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
75 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
76 |
77 | RssItem* item = [ [ [ RssItem alloc ] init ] autorelease ];
78 | item.Title = @"Персональный батискаф";
79 | item.GUID = @"http://itw66.ru/blog/interesting_things/743.html";
80 | item.Link = @"http://itw66.ru/blog/interesting_things/743.html";
81 | item.Desc = @" Жак=Ив Кусто, один из создателей акваланга, является одним из самых известных исследователей морей и океанов. Всем хорошо известна «Подводная одиссея команды Кусто». Кроме того, один из его первых цветных подводных фильмов был удостоен Пальмовой Ветви в Каннах в 1956 году. Кусто успел повидать и поведать нам о многом, но несмотря на это морское дно хранит еще много тайн о жизни на Земле. С начала исследований морского дна и во многом благодаря им были сделаны существенные технологические и экологические открытия. Совсем недавно, в 2010 году, в своей речи на событии Mission Blue, организованном TED, океанограф Эдит Виддер (Edith Widder) говорила об исследовании водной части Земли и заметила, что в исследование морских глубин денег вкладывается гораздо меньше, чем например в исследовании космоса, хотя на данный момент всего около 5% океанов исследовано человеком. Она также заметила, что исследования — это сила, которая движет инновациями. Ее призыв услышал дизайнер Эдуардо Гальвани (Eduardo Galvani), который предложил проект персонального батискафа — Manatee, для создания возможности персонального изучения морских глубин.подробности... ";
82 | item.PubDate = [ fmt dateFromString: @"Thu, 03 Jul 2014 12:56:57 +0400" ];
83 | item.Categories = [ NSArray arrayWithObjects: @"батискаф", @"персональный", @"manatee", @"Eduardo Galvani", nil ];
84 |
85 | RssItem* item2 = [ [ [ RssItem alloc ] init ] autorelease ];
86 | item2.Title = @"Новый взгляд на ветряную турбину!";
87 | item2.GUID = @"http://itw66.ru/blog/alternative_energy/742.html";
88 | item2.Link = @"http://itw66.ru/blog/alternative_energy/742.html";
89 | item2.Desc = @"img src=\"http://itw66.ru/uploads/images/00/00/01/2014/06/23/2f7842.jpg\"/> Все мы уже привыкли к традиционным формам ветряков, которые конструкцию свою получили от достаточно древних ветряных мельниц. У них есть как свои плюсы, так и свои минусы. Специалисты из компании Solar Wind Energy Inc. задумались над тем, как решить проблему отсутствия ветра, а заодно и повышения КПД устройства. В итоге они изобрели Solar Wind Downdraft Tower, башню, которая для генерации электричества может создавать свой собственный ветер. Как это может работать? Читайте далее…а вот как... ";
90 | item2.PubDate = [ fmt dateFromString: @"Mon, 23 Jun 2014 21:45:20 +0400" ];
91 | item2.Categories = [ NSArray arrayWithObjects: @"Solar Wind Energy Inc", @"Downdraft Tower", @"башня-ветряк", nil ];
92 |
93 | ch.Items = [ NSArray arrayWithObjects: item, item2, nil ];
94 |
95 | return ch;
96 | }
97 |
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/RssItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssItem : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* GUID;
15 | @property ( nonatomic, copy ) NSString* Link;
16 | @property ( nonatomic, copy ) NSString* Desc;
17 | @property ( nonatomic, retain ) NSDate* PubDate;
18 | @property ( nonatomic, retain ) NSArray* Categories;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/RssItem.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 |
11 | @implementation RssItem
12 | {
13 | NSString* _title;
14 | NSString* _guid;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSDate* _pubDate;
18 | NSArray* _categories;
19 | }
20 |
21 | @synthesize Title = _title;
22 | @synthesize GUID = _guid;
23 | @synthesize Link = _link;
24 | @synthesize Desc = _desc;
25 | @synthesize PubDate = _pubDate;
26 | @synthesize Categories = _categories;
27 |
28 | -( id ) init
29 | {
30 | self = [ super init ];
31 |
32 | if ( nil != self )
33 | {
34 | // TODO:
35 | }
36 |
37 | return self;
38 | }
39 |
40 | -( void ) dealloc
41 | {
42 | [ _title release ];
43 | [ _guid release ];
44 | [ _link release ];
45 | [ _desc release ];
46 | [ _pubDate release ];
47 | [ _categories release ];
48 |
49 | [ super dealloc ];
50 | }
51 |
52 | -( NSString* ) description
53 | {
54 | NSMutableString* str = [ NSMutableString string ];
55 |
56 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
57 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
58 |
59 | [ str appendFormat: @"\t\tTitle: %@\n", _title ];
60 | [ str appendFormat: @"\t\tGUID: %@\n", _guid ];
61 | [ str appendFormat: @"\t\tLink: %@\n", _link ];
62 | [ str appendFormat: @"\t\tDesc: %@\n", _desc ];
63 | [ str appendFormat: @"\t\tPubDate: %@\n", [ fmt stringFromDate: _pubDate ] ];
64 | [ str appendFormat: @"\t\tCategories: " ];
65 |
66 | for ( NSString* cat in _categories )
67 | {
68 | [ str appendFormat: @"%@, ", cat ];
69 | }
70 | [ str appendFormat: @"\n" ];
71 |
72 | return [ NSString stringWithString: str ];
73 | }
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/RssParser.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssParser.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 14/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RSS.h"
12 |
13 | @interface RssParser : NSObject
14 |
15 | -( RSS* ) parseRssFeedFromFile: ( NSString* )filePath;
16 | -( RSS* ) parseRssFeedFromData: ( NSData* )data;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/iosc.02-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/iosc.02-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_3_0
10 | #warning "This project uses features only available in iOS SDK 3.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02Tests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02Tests/iosc.02Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 3/iosc.02Tests/iosc_02Tests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iosc_02Tests.m
3 | // iosc.02Tests
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iosc_02Tests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iosc_02Tests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property ( nonatomic, retain ) UIWindow* Window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | #import "RSS.h"
12 | #import "RssItem.h"
13 | #import "RssChannel.h"
14 | #import "RssParser.h"
15 |
16 | #import "RssItemViewController.h"
17 |
18 | @interface AppDelegate ( ) < RssLoadingProtocol >
19 |
20 | -( void ) rssLoaded: ( RSS* )rss;
21 |
22 | @end
23 |
24 | @implementation AppDelegate
25 | {
26 | UIWindow* _window;
27 | RssItemViewController* _itemCtrl;
28 | }
29 |
30 | -( void ) dealloc
31 | {
32 | [ _itemCtrl release ];
33 | [ _window release ];
34 |
35 | [ super dealloc ];
36 | }
37 |
38 | -( void ) rssLoaded: ( RSS* )rss
39 | {
40 | NSLog( @"RSS loaded (TS): %@", [ rss description ] );
41 | }
42 |
43 | -( void ) didSucceededLoadRSS: ( RSS* )rss
44 | {
45 | NSLog( @"RSS loaded (Prot): %@", [ rss description ] );
46 | [ _itemCtrl setRssItem: ( RssItem* )[ ( ( RssChannel* ) [ rss.Channels objectAtIndex: 0 ] ).Items objectAtIndex: 0 ] ];
47 | }
48 |
49 | -( void ) didRSSLoadFailed: ( NSError* )error
50 | {
51 | NSLog( @"RSS load failed: %@ [ %@ ] ", error, [ error userInfo ] );
52 | }
53 |
54 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
55 | {
56 | _window = [ [ UIWindow alloc ] initWithFrame: [ [ UIScreen mainScreen ] bounds ] ];
57 | _window.backgroundColor = [ UIColor whiteColor ];
58 |
59 | _itemCtrl = [ [ RssItemViewController alloc ] initWithNibName: @"RssItemViewController" bundle: [ NSBundle mainBundle ] ];
60 | _window.rootViewController = _itemCtrl;
61 | [ _window makeKeyAndVisible ];
62 |
63 | /*
64 | RSS* rss = [ RSS sample ];
65 | NSLog( @"%@", [ rss description ] );
66 | */
67 |
68 | [ RSS loadRssFromFile: @"file.sample.txt" target: self selector: @selector( rssLoaded: ) ];
69 | [ RSS loadRssFromFile: [ [ NSBundle mainBundle ] pathForResource: @"rss" ofType: @"xml" ] thenCallback: self ];
70 |
71 | return YES;
72 | }
73 |
74 | - (void)applicationWillResignActive:(UIApplication *)application
75 | {
76 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
77 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
78 | }
79 |
80 | - (void)applicationDidEnterBackground:(UIApplication *)application
81 | {
82 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
83 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
84 | }
85 |
86 | - (void)applicationWillEnterForeground:(UIApplication *)application
87 | {
88 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
89 | }
90 |
91 | - (void)applicationDidBecomeActive:(UIApplication *)application
92 | {
93 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
94 | }
95 |
96 | - (void)applicationWillTerminate:(UIApplication *)application
97 | {
98 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
99 | }
100 |
101 | @end
102 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "size" : "29x29",
21 | "scale" : "1x"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "size" : "29x29",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "size" : "40x40",
31 | "scale" : "1x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "40x40",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "76x76",
41 | "scale" : "1x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "76x76",
46 | "scale" : "2x"
47 | }
48 | ],
49 | "info" : {
50 | "version" : 1,
51 | "author" : "xcode"
52 | }
53 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RSS.h:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RSS;
12 |
13 | @protocol RssLoadingProtocol
14 |
15 | -( void ) didSucceededLoadRSS: ( RSS* )rss;
16 | -( void ) didRSSLoadFailed: ( NSError* )error;
17 |
18 | @end
19 |
20 | @interface RSS : NSObject
21 |
22 | @property ( nonatomic, retain ) NSArray* Channels;
23 |
24 | +( RSS* ) sample;
25 |
26 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector;
27 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RSS.m:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RSS.h"
10 | #import "RssChannel.h"
11 | #import "RssItem.h"
12 |
13 | #import "RssParser.h"
14 |
15 | @implementation RSS
16 | {
17 | NSArray* _channels;
18 | }
19 |
20 | @synthesize Channels = _channels;
21 |
22 | -( id ) init
23 | {
24 | self = [ super init ];
25 |
26 | if ( nil != self )
27 | {
28 | // TODO:
29 | }
30 |
31 | return self;
32 | }
33 |
34 | -( void ) dealloc
35 | {
36 | [ _channels release ];
37 |
38 | [ super dealloc ];
39 | }
40 |
41 | -( NSString* ) description
42 | {
43 | NSMutableString* str = [ NSMutableString string ];
44 |
45 | [ str appendFormat: @"Channels:\n" ];
46 |
47 | for ( RssChannel* ch in _channels )
48 | {
49 | [ str appendFormat: @"%@\n", [ ch description ] ];
50 | }
51 |
52 | return [ NSString stringWithString: str ];
53 | }
54 |
55 | #pragma mark - public routines
56 |
57 | +( RSS* ) sample
58 | {
59 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
60 |
61 | RssChannel* ch = [ RssChannel sampleChannel ];
62 |
63 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
64 |
65 | return rss;
66 | }
67 |
68 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector
69 | {
70 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
71 | RssChannel* ch = [ RssChannel sampleChannel ];
72 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
73 |
74 | if ( [ target respondsToSelector: selector ] )
75 | [ target performSelector: selector withObject: rss ];
76 | }
77 |
78 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback
79 | {
80 | RssParser* parser = [ [ [ RssParser alloc ] init ] autorelease ];
81 | RSS* rss = [ parser parseRssFeedFromFile: fileName ];
82 |
83 | if ( nil != callback )
84 | [ callback didSucceededLoadRSS: rss ];
85 | }
86 |
87 |
88 | @end
89 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RssChannel.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssChannel : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* Link;
15 | @property ( nonatomic, copy ) NSString* Desc;
16 | @property ( nonatomic, retain ) NSArray* Items;
17 |
18 | +( RssChannel* ) sampleChannel;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RssChannel.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 | #import "RssChannel.h"
11 |
12 | @implementation RssChannel
13 | {
14 | NSString* _title;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSArray* _items;
18 | }
19 |
20 | @synthesize Title = _title;
21 | @synthesize Link = _link;
22 | @synthesize Desc = _desc;
23 | @synthesize Items = _items;
24 |
25 | -( id ) init
26 | {
27 | self = [ super init ];
28 |
29 | if ( nil != self )
30 | {
31 | // TODO:
32 | }
33 |
34 | return self;
35 | }
36 |
37 | -( void ) dealloc
38 | {
39 | [ _title release ];
40 | [ _link release ];
41 | [ _desc release ];
42 | [ _items release ];
43 |
44 | [ super dealloc ];
45 | }
46 |
47 | -( NSString* ) description
48 | {
49 | NSMutableString* str = [ NSMutableString string ];
50 |
51 | [ str appendFormat: @"\tTitle: %@\n", _title ];
52 | [ str appendFormat: @"\tLink: %@\n", _link ];
53 | [ str appendFormat: @"\tDesc: %@\n", _desc ];
54 | [ str appendFormat: @"\tItems:\n" ];
55 |
56 | for ( RssItem* item in _items )
57 | {
58 | [ str appendFormat: @"%@\n", [ item description ] ];
59 | }
60 |
61 | return [ NSString stringWithString: str ];
62 | }
63 |
64 | #pragma mark - public routines
65 |
66 | +( RssChannel* ) sampleChannel
67 | {
68 | RssChannel* ch = [ [ [ RssChannel alloc] init ] autorelease ];
69 |
70 | ch.Title = @"it works!";
71 | ch.Link = @"http://itw66.ru";
72 | ch.Desc = @"it works! / RSS channel";
73 |
74 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
75 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
76 |
77 | RssItem* item = [ [ [ RssItem alloc ] init ] autorelease ];
78 | item.Title = @"Персональный батискаф";
79 | item.GUID = @"http://itw66.ru/blog/interesting_things/743.html";
80 | item.Link = @"http://itw66.ru/blog/interesting_things/743.html";
81 | item.Desc = @" Жак=Ив Кусто, один из создателей акваланга, является одним из самых известных исследователей морей и океанов. Всем хорошо известна «Подводная одиссея команды Кусто». Кроме того, один из его первых цветных подводных фильмов был удостоен Пальмовой Ветви в Каннах в 1956 году. Кусто успел повидать и поведать нам о многом, но несмотря на это морское дно хранит еще много тайн о жизни на Земле. С начала исследований морского дна и во многом благодаря им были сделаны существенные технологические и экологические открытия. Совсем недавно, в 2010 году, в своей речи на событии Mission Blue, организованном TED, океанограф Эдит Виддер (Edith Widder) говорила об исследовании водной части Земли и заметила, что в исследование морских глубин денег вкладывается гораздо меньше, чем например в исследовании космоса, хотя на данный момент всего около 5% океанов исследовано человеком. Она также заметила, что исследования — это сила, которая движет инновациями. Ее призыв услышал дизайнер Эдуардо Гальвани (Eduardo Galvani), который предложил проект персонального батискафа — Manatee, для создания возможности персонального изучения морских глубин.подробности... ";
82 | item.PubDate = [ fmt dateFromString: @"Thu, 03 Jul 2014 12:56:57 +0400" ];
83 | item.Categories = [ NSArray arrayWithObjects: @"батискаф", @"персональный", @"manatee", @"Eduardo Galvani", nil ];
84 |
85 | RssItem* item2 = [ [ [ RssItem alloc ] init ] autorelease ];
86 | item2.Title = @"Новый взгляд на ветряную турбину!";
87 | item2.GUID = @"http://itw66.ru/blog/alternative_energy/742.html";
88 | item2.Link = @"http://itw66.ru/blog/alternative_energy/742.html";
89 | item2.Desc = @"img src=\"http://itw66.ru/uploads/images/00/00/01/2014/06/23/2f7842.jpg\"/> Все мы уже привыкли к традиционным формам ветряков, которые конструкцию свою получили от достаточно древних ветряных мельниц. У них есть как свои плюсы, так и свои минусы. Специалисты из компании Solar Wind Energy Inc. задумались над тем, как решить проблему отсутствия ветра, а заодно и повышения КПД устройства. В итоге они изобрели Solar Wind Downdraft Tower, башню, которая для генерации электричества может создавать свой собственный ветер. Как это может работать? Читайте далее…а вот как... ";
90 | item2.PubDate = [ fmt dateFromString: @"Mon, 23 Jun 2014 21:45:20 +0400" ];
91 | item2.Categories = [ NSArray arrayWithObjects: @"Solar Wind Energy Inc", @"Downdraft Tower", @"башня-ветряк", nil ];
92 |
93 | ch.Items = [ NSArray arrayWithObjects: item, item2, nil ];
94 |
95 | return ch;
96 | }
97 |
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RssItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssItem : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* GUID;
15 | @property ( nonatomic, copy ) NSString* Link;
16 | @property ( nonatomic, copy ) NSString* Desc;
17 | @property ( nonatomic, retain ) NSDate* PubDate;
18 | @property ( nonatomic, retain ) NSArray* Categories;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RssItem.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 |
11 | @implementation RssItem
12 | {
13 | NSString* _title;
14 | NSString* _guid;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSDate* _pubDate;
18 | NSArray* _categories;
19 | }
20 |
21 | @synthesize Title = _title;
22 | @synthesize GUID = _guid;
23 | @synthesize Link = _link;
24 | @synthesize Desc = _desc;
25 | @synthesize PubDate = _pubDate;
26 | @synthesize Categories = _categories;
27 |
28 | -( id ) init
29 | {
30 | self = [ super init ];
31 |
32 | if ( nil != self )
33 | {
34 | // TODO:
35 | }
36 |
37 | return self;
38 | }
39 |
40 | -( void ) dealloc
41 | {
42 | [ _title release ];
43 | [ _guid release ];
44 | [ _link release ];
45 | [ _desc release ];
46 | [ _pubDate release ];
47 | [ _categories release ];
48 |
49 | [ super dealloc ];
50 | }
51 |
52 | -( NSString* ) description
53 | {
54 | NSMutableString* str = [ NSMutableString string ];
55 |
56 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
57 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
58 |
59 | [ str appendFormat: @"\t\tTitle: %@\n", _title ];
60 | [ str appendFormat: @"\t\tGUID: %@\n", _guid ];
61 | [ str appendFormat: @"\t\tLink: %@\n", _link ];
62 | [ str appendFormat: @"\t\tDesc: %@\n", _desc ];
63 | [ str appendFormat: @"\t\tPubDate: %@\n", [ fmt stringFromDate: _pubDate ] ];
64 | [ str appendFormat: @"\t\tCategories: " ];
65 |
66 | for ( NSString* cat in _categories )
67 | {
68 | [ str appendFormat: @"%@, ", cat ];
69 | }
70 | [ str appendFormat: @"\n" ];
71 |
72 | return [ NSString stringWithString: str ];
73 | }
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RssItemViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemViewController.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RssItem;
12 |
13 | @interface RssItemViewController : UIViewController
14 |
15 | -( void ) setRssItem: ( RssItem* )item;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RssItemViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemViewController.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItemViewController.h"
10 |
11 | #import "RssItem.h"
12 |
13 | @interface RssItemViewController ( )
14 |
15 | @property ( nonatomic, retain ) IBOutlet UIImageView* ImageView;
16 | @property ( nonatomic, retain ) IBOutlet UILabel* TitleView;
17 | @property ( nonatomic, retain ) IBOutlet UIWebView* DescriptionView;
18 |
19 | @end
20 |
21 | @implementation RssItemViewController
22 | {
23 | UIImageView* _imageView;
24 | UILabel* _titleView;
25 | UIWebView* _descriptionView;
26 | }
27 |
28 | @synthesize ImageView = _imageView;
29 | @synthesize TitleView = _titleView;
30 | @synthesize DescriptionView = _descriptionView;
31 |
32 | -( id ) initWithNibName: ( NSString* )nibNameOrNil bundle: ( NSBundle* )nibBundleOrNil
33 | {
34 | self = [ super initWithNibName: nibNameOrNil bundle: nibBundleOrNil ];
35 |
36 | if ( nil != self )
37 | {
38 | }
39 |
40 | return self;
41 | }
42 |
43 | -( void ) dealloc
44 | {
45 | [ _imageView release ];
46 | [ _titleView release ];
47 | [ _descriptionView release ];
48 |
49 | [ super dealloc ];
50 | }
51 |
52 | -( void ) viewDidLoad
53 | {
54 | [ super viewDidLoad ];
55 |
56 | _titleView.text = @"";
57 | [ _descriptionView loadHTMLString: @"" baseURL: nil ];
58 | }
59 |
60 | -( void ) didReceiveMemoryWarning
61 | {
62 | [ super didReceiveMemoryWarning ];
63 | }
64 |
65 | #pragma mark - public routines
66 |
67 | -( void ) setRssItem: ( RssItem* )item
68 | {
69 | _titleView.text = item.Title;
70 | [ _descriptionView loadHTMLString: item.Desc baseURL: nil ];
71 |
72 | NSDataDetector* detector = [ NSDataDetector dataDetectorWithTypes: NSTextCheckingTypeLink error: nil ];
73 | NSArray* matches = [ detector matchesInString: item.Desc options: 0 range: NSMakeRange( 0, [ item.Desc length ] ) ];
74 | if ( [ matches count ] > 0 )
75 | {
76 | NSTextCheckingResult* match = [ matches objectAtIndex: 0 ];
77 | if ( [ match resultType ] == NSTextCheckingTypeLink )
78 | {
79 | NSURL* url = [ match URL ];
80 | NSData* data = [ NSData dataWithContentsOfURL: url ];
81 | UIImage* img = [ UIImage imageWithData: data ];
82 | _imageView.image = img;
83 | }
84 | else
85 | {
86 | _imageView.image = nil;
87 | }
88 | }
89 | else
90 | {
91 | _imageView.image = nil;
92 | }
93 | }
94 |
95 |
96 | @end
97 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RssItemViewController.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/RssParser.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssParser.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 14/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RSS.h"
12 |
13 | @interface RssParser : NSObject
14 |
15 | -( RSS* ) parseRssFeedFromFile: ( NSString* )filePath;
16 | -( RSS* ) parseRssFeedFromData: ( NSData* )data;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/iosc.02-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/iosc.02-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_3_0
10 | #warning "This project uses features only available in iOS SDK 3.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02Tests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02Tests/iosc.02Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 4/iosc.02Tests/iosc_02Tests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iosc_02Tests.m
3 | // iosc.02Tests
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iosc_02Tests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iosc_02Tests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property ( nonatomic, retain ) UIWindow* Window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | #import "RSS.h"
12 | #import "RssItem.h"
13 | #import "RssChannel.h"
14 | #import "RssParser.h"
15 |
16 | #import "RssItemViewController.h"
17 | #import "RssChannelViewController.h"
18 |
19 | @interface AppDelegate ( ) < RssLoadingProtocol >
20 |
21 | -( void ) rssLoaded: ( RSS* )rss;
22 |
23 | @end
24 |
25 | @implementation AppDelegate
26 | {
27 | UIWindow* _window;
28 | RssChannelViewController* _ctrl;
29 | }
30 |
31 | -( void ) dealloc
32 | {
33 | [ _ctrl release ];
34 | [ _window release ];
35 |
36 | [ super dealloc ];
37 | }
38 |
39 | -( void ) rssLoaded: ( RSS* )rss
40 | {
41 | NSLog( @"RSS loaded (TS): %@", [ rss description ] );
42 | }
43 |
44 | -( void ) didSucceededLoadRSS: ( RSS* )rss
45 | {
46 | NSLog( @"RSS loaded (Prot): %@", [ rss description ] );
47 |
48 | _ctrl.Channel = [ rss.Channels objectAtIndex: 0 ];
49 | }
50 |
51 | -( void ) didRSSLoadFailed: ( NSError* )error
52 | {
53 | NSLog( @"RSS load failed: %@ [ %@ ] ", error, [ error userInfo ] );
54 | }
55 |
56 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
57 | {
58 | _window = [ [ UIWindow alloc ] initWithFrame: [ [ UIScreen mainScreen ] bounds ] ];
59 | _window.backgroundColor = [ UIColor whiteColor ];
60 |
61 | _ctrl = [ [ RssChannelViewController alloc ] initWithNibName: @"RssChannelViewController" bundle: [ NSBundle mainBundle ] ];
62 | [ RSS loadRssFromFile: @"file.sample.txt" target: self selector: @selector( rssLoaded: ) ];
63 | [ RSS loadRssFromFile: [ [ NSBundle mainBundle ] pathForResource: @"rss" ofType: @"xml" ] thenCallback: self ];
64 |
65 | UINavigationController* navctrl = [ [ [ UINavigationController alloc ] initWithRootViewController: _ctrl ] autorelease ];
66 | navctrl.navigationBar.barStyle = UIBarStyleBlackOpaque;
67 |
68 | _window.rootViewController = navctrl;
69 | [ _window makeKeyAndVisible ];
70 |
71 | /*
72 | RSS* rss = [ RSS sample ];
73 | NSLog( @"%@", [ rss description ] );
74 | */
75 |
76 | return YES;
77 | }
78 |
79 | - (void)applicationWillResignActive:(UIApplication *)application
80 | {
81 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
82 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
83 | }
84 |
85 | - (void)applicationDidEnterBackground:(UIApplication *)application
86 | {
87 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
88 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
89 | }
90 |
91 | - (void)applicationWillEnterForeground:(UIApplication *)application
92 | {
93 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
94 | }
95 |
96 | - (void)applicationDidBecomeActive:(UIApplication *)application
97 | {
98 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
99 | }
100 |
101 | - (void)applicationWillTerminate:(UIApplication *)application
102 | {
103 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
104 | }
105 |
106 | @end
107 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "size" : "29x29",
21 | "scale" : "1x"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "size" : "29x29",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "size" : "40x40",
31 | "scale" : "1x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "40x40",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "76x76",
41 | "scale" : "1x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "76x76",
46 | "scale" : "2x"
47 | }
48 | ],
49 | "info" : {
50 | "version" : 1,
51 | "author" : "xcode"
52 | }
53 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RSS.h:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RSS;
12 |
13 | @protocol RssLoadingProtocol
14 |
15 | -( void ) didSucceededLoadRSS: ( RSS* )rss;
16 | -( void ) didRSSLoadFailed: ( NSError* )error;
17 |
18 | @end
19 |
20 | @interface RSS : NSObject
21 |
22 | @property ( nonatomic, retain ) NSArray* Channels;
23 |
24 | +( RSS* ) sample;
25 |
26 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector;
27 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RSS.m:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RSS.h"
10 | #import "RssChannel.h"
11 | #import "RssItem.h"
12 |
13 | #import "RssParser.h"
14 |
15 | @implementation RSS
16 | {
17 | NSArray* _channels;
18 | }
19 |
20 | @synthesize Channels = _channels;
21 |
22 | -( id ) init
23 | {
24 | self = [ super init ];
25 |
26 | if ( nil != self )
27 | {
28 | // TODO:
29 | }
30 |
31 | return self;
32 | }
33 |
34 | -( void ) dealloc
35 | {
36 | [ _channels release ];
37 |
38 | [ super dealloc ];
39 | }
40 |
41 | -( NSString* ) description
42 | {
43 | NSMutableString* str = [ NSMutableString string ];
44 |
45 | [ str appendFormat: @"Channels:\n" ];
46 |
47 | for ( RssChannel* ch in _channels )
48 | {
49 | [ str appendFormat: @"%@\n", [ ch description ] ];
50 | }
51 |
52 | return [ NSString stringWithString: str ];
53 | }
54 |
55 | #pragma mark - public routines
56 |
57 | +( RSS* ) sample
58 | {
59 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
60 |
61 | RssChannel* ch = [ RssChannel sampleChannel ];
62 |
63 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
64 |
65 | return rss;
66 | }
67 |
68 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector
69 | {
70 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
71 | RssChannel* ch = [ RssChannel sampleChannel ];
72 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
73 |
74 | if ( [ target respondsToSelector: selector ] )
75 | [ target performSelector: selector withObject: rss ];
76 | }
77 |
78 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback
79 | {
80 | RssParser* parser = [ [ [ RssParser alloc ] init ] autorelease ];
81 | RSS* rss = [ parser parseRssFeedFromFile: fileName ];
82 |
83 | if ( nil != callback )
84 | [ callback didSucceededLoadRSS: rss ];
85 | }
86 |
87 |
88 | @end
89 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssChannel.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssChannel : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* Link;
15 | @property ( nonatomic, copy ) NSString* Desc;
16 | @property ( nonatomic, retain ) NSArray* Items;
17 |
18 | +( RssChannel* ) sampleChannel;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssChannel.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 | #import "RssChannel.h"
11 |
12 | @implementation RssChannel
13 | {
14 | NSString* _title;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSArray* _items;
18 | }
19 |
20 | @synthesize Title = _title;
21 | @synthesize Link = _link;
22 | @synthesize Desc = _desc;
23 | @synthesize Items = _items;
24 |
25 | -( id ) init
26 | {
27 | self = [ super init ];
28 |
29 | if ( nil != self )
30 | {
31 | // TODO:
32 | }
33 |
34 | return self;
35 | }
36 |
37 | -( void ) dealloc
38 | {
39 | [ _title release ];
40 | [ _link release ];
41 | [ _desc release ];
42 | [ _items release ];
43 |
44 | [ super dealloc ];
45 | }
46 |
47 | -( NSString* ) description
48 | {
49 | NSMutableString* str = [ NSMutableString string ];
50 |
51 | [ str appendFormat: @"\tTitle: %@\n", _title ];
52 | [ str appendFormat: @"\tLink: %@\n", _link ];
53 | [ str appendFormat: @"\tDesc: %@\n", _desc ];
54 | [ str appendFormat: @"\tItems:\n" ];
55 |
56 | for ( RssItem* item in _items )
57 | {
58 | [ str appendFormat: @"%@\n", [ item description ] ];
59 | }
60 |
61 | return [ NSString stringWithString: str ];
62 | }
63 |
64 | #pragma mark - public routines
65 |
66 | +( RssChannel* ) sampleChannel
67 | {
68 | RssChannel* ch = [ [ [ RssChannel alloc] init ] autorelease ];
69 |
70 | ch.Title = @"it works!";
71 | ch.Link = @"http://itw66.ru";
72 | ch.Desc = @"it works! / RSS channel";
73 |
74 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
75 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
76 |
77 | RssItem* item = [ [ [ RssItem alloc ] init ] autorelease ];
78 | item.Title = @"Персональный батискаф";
79 | item.GUID = @"http://itw66.ru/blog/interesting_things/743.html";
80 | item.Link = @"http://itw66.ru/blog/interesting_things/743.html";
81 | item.Desc = @" Жак=Ив Кусто, один из создателей акваланга, является одним из самых известных исследователей морей и океанов. Всем хорошо известна «Подводная одиссея команды Кусто». Кроме того, один из его первых цветных подводных фильмов был удостоен Пальмовой Ветви в Каннах в 1956 году. Кусто успел повидать и поведать нам о многом, но несмотря на это морское дно хранит еще много тайн о жизни на Земле. С начала исследований морского дна и во многом благодаря им были сделаны существенные технологические и экологические открытия. Совсем недавно, в 2010 году, в своей речи на событии Mission Blue, организованном TED, океанограф Эдит Виддер (Edith Widder) говорила об исследовании водной части Земли и заметила, что в исследование морских глубин денег вкладывается гораздо меньше, чем например в исследовании космоса, хотя на данный момент всего около 5% океанов исследовано человеком. Она также заметила, что исследования — это сила, которая движет инновациями. Ее призыв услышал дизайнер Эдуардо Гальвани (Eduardo Galvani), который предложил проект персонального батискафа — Manatee, для создания возможности персонального изучения морских глубин.подробности... ";
82 | item.PubDate = [ fmt dateFromString: @"Thu, 03 Jul 2014 12:56:57 +0400" ];
83 | item.Categories = [ NSArray arrayWithObjects: @"батискаф", @"персональный", @"manatee", @"Eduardo Galvani", nil ];
84 |
85 | RssItem* item2 = [ [ [ RssItem alloc ] init ] autorelease ];
86 | item2.Title = @"Новый взгляд на ветряную турбину!";
87 | item2.GUID = @"http://itw66.ru/blog/alternative_energy/742.html";
88 | item2.Link = @"http://itw66.ru/blog/alternative_energy/742.html";
89 | item2.Desc = @"img src=\"http://itw66.ru/uploads/images/00/00/01/2014/06/23/2f7842.jpg\"/> Все мы уже привыкли к традиционным формам ветряков, которые конструкцию свою получили от достаточно древних ветряных мельниц. У них есть как свои плюсы, так и свои минусы. Специалисты из компании Solar Wind Energy Inc. задумались над тем, как решить проблему отсутствия ветра, а заодно и повышения КПД устройства. В итоге они изобрели Solar Wind Downdraft Tower, башню, которая для генерации электричества может создавать свой собственный ветер. Как это может работать? Читайте далее…а вот как... ";
90 | item2.PubDate = [ fmt dateFromString: @"Mon, 23 Jun 2014 21:45:20 +0400" ];
91 | item2.Categories = [ NSArray arrayWithObjects: @"Solar Wind Energy Inc", @"Downdraft Tower", @"башня-ветряк", nil ];
92 |
93 | ch.Items = [ NSArray arrayWithObjects: item, item2, nil ];
94 |
95 | return ch;
96 | }
97 |
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssChannelViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannelViewController.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RssChannel;
12 |
13 | @interface RssChannelViewController : UIViewController
14 |
15 | @property ( nonatomic, retain ) RssChannel* Channel;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssChannelViewController.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssItem : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* GUID;
15 | @property ( nonatomic, copy ) NSString* Link;
16 | @property ( nonatomic, copy ) NSString* Desc;
17 | @property ( nonatomic, retain ) NSDate* PubDate;
18 | @property ( nonatomic, retain ) NSArray* Categories;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssItem.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 |
11 | @implementation RssItem
12 | {
13 | NSString* _title;
14 | NSString* _guid;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSDate* _pubDate;
18 | NSArray* _categories;
19 | }
20 |
21 | @synthesize Title = _title;
22 | @synthesize GUID = _guid;
23 | @synthesize Link = _link;
24 | @synthesize Desc = _desc;
25 | @synthesize PubDate = _pubDate;
26 | @synthesize Categories = _categories;
27 |
28 | -( id ) init
29 | {
30 | self = [ super init ];
31 |
32 | if ( nil != self )
33 | {
34 | // TODO:
35 | }
36 |
37 | return self;
38 | }
39 |
40 | -( void ) dealloc
41 | {
42 | [ _title release ];
43 | [ _guid release ];
44 | [ _link release ];
45 | [ _desc release ];
46 | [ _pubDate release ];
47 | [ _categories release ];
48 |
49 | [ super dealloc ];
50 | }
51 |
52 | -( NSString* ) description
53 | {
54 | NSMutableString* str = [ NSMutableString string ];
55 |
56 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
57 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
58 |
59 | [ str appendFormat: @"\t\tTitle: %@\n", _title ];
60 | [ str appendFormat: @"\t\tGUID: %@\n", _guid ];
61 | [ str appendFormat: @"\t\tLink: %@\n", _link ];
62 | [ str appendFormat: @"\t\tDesc: %@\n", _desc ];
63 | [ str appendFormat: @"\t\tPubDate: %@\n", [ fmt stringFromDate: _pubDate ] ];
64 | [ str appendFormat: @"\t\tCategories: " ];
65 |
66 | for ( NSString* cat in _categories )
67 | {
68 | [ str appendFormat: @"%@, ", cat ];
69 | }
70 | [ str appendFormat: @"\n" ];
71 |
72 | return [ NSString stringWithString: str ];
73 | }
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssItemViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemViewController.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RssItem;
12 |
13 | @interface RssItemViewController : UIViewController
14 |
15 | @property ( nonatomic, retain ) RssItem* Item;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssItemViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemViewController.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItemViewController.h"
10 |
11 | #import "RssItem.h"
12 |
13 | @interface RssItemViewController ( )
14 |
15 | @property ( nonatomic, retain ) IBOutlet UIImageView* ImageView;
16 | @property ( nonatomic, retain ) IBOutlet UILabel* TitleView;
17 | @property ( nonatomic, retain ) IBOutlet UIWebView* DescriptionView;
18 |
19 | @end
20 |
21 | @implementation RssItemViewController
22 | {
23 | UIImageView* _imageView;
24 | UILabel* _titleView;
25 | UIWebView* _descriptionView;
26 |
27 | RssItem* _item;
28 | }
29 |
30 | @synthesize ImageView = _imageView;
31 | @synthesize TitleView = _titleView;
32 | @synthesize DescriptionView = _descriptionView;
33 |
34 | @synthesize Item = _item;
35 |
36 | -( id ) initWithNibName: ( NSString* )nibNameOrNil bundle: ( NSBundle* )nibBundleOrNil
37 | {
38 | self = [ super initWithNibName: nibNameOrNil bundle: nibBundleOrNil ];
39 |
40 | if ( nil != self )
41 | {
42 | }
43 |
44 | return self;
45 | }
46 |
47 | -( void ) dealloc
48 | {
49 | [ _imageView release ];
50 | [ _titleView release ];
51 | [ _descriptionView release ];
52 |
53 | [ _item release ];
54 |
55 | [ super dealloc ];
56 | }
57 |
58 | -( void ) viewDidLoad
59 | {
60 | [ super viewDidLoad ];
61 |
62 | self.edgesForExtendedLayout = UIRectEdgeNone;
63 |
64 | _titleView.text = @"";
65 | [ _descriptionView loadHTMLString: @"" baseURL: nil ];
66 | }
67 |
68 | -( void ) viewDidAppear: ( BOOL )animated
69 | {
70 | [ super viewDidAppear: animated ];
71 |
72 | [ self setItem: _item ];
73 | }
74 |
75 | -( void ) viewWillAppear: ( BOOL )animated
76 | {
77 | [ super viewWillAppear: animated ];
78 |
79 | self.navigationItem.title = _item.Title;
80 | self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
81 | }
82 |
83 | -( void ) didReceiveMemoryWarning
84 | {
85 | [ super didReceiveMemoryWarning ];
86 | }
87 |
88 | #pragma mark - public routines
89 |
90 | -( void ) setItem: ( RssItem* )item
91 | {
92 | [ _item release ];
93 | _item = [ item retain ];
94 |
95 | _titleView.text = item.Title;
96 | [ _descriptionView loadHTMLString: item.Desc baseURL: nil ];
97 |
98 | NSDataDetector* detector = [ NSDataDetector dataDetectorWithTypes: NSTextCheckingTypeLink error: nil ];
99 | NSArray* matches = [ detector matchesInString: item.Desc options: 0 range: NSMakeRange( 0, [ item.Desc length ] ) ];
100 | if ( [ matches count ] > 0 )
101 | {
102 | NSTextCheckingResult* match = [ matches objectAtIndex: 0 ];
103 | if ( [ match resultType ] == NSTextCheckingTypeLink )
104 | {
105 | NSURL* url = [ match URL ];
106 | NSData* data = [ NSData dataWithContentsOfURL: url ];
107 | UIImage* img = [ UIImage imageWithData: data ];
108 | _imageView.image = img;
109 | }
110 | else
111 | {
112 | _imageView.image = nil;
113 | }
114 | }
115 | else
116 | {
117 | _imageView.image = nil;
118 | }
119 | }
120 |
121 |
122 | @end
123 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssItemViewController.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/RssParser.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssParser.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 14/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RSS.h"
12 |
13 | @interface RssParser : NSObject
14 |
15 | -( RSS* ) parseRssFeedFromFile: ( NSString* )filePath;
16 | -( RSS* ) parseRssFeedFromData: ( NSData* )data;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/UIImage+Colored.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Colored.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage ( Colored )
12 |
13 | +( UIImage* ) imageWithColor: ( UIColor* )color;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/UIImage+Colored.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Colored.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "UIImage+Colored.h"
10 |
11 | @implementation UIImage ( Colored )
12 |
13 | +( UIImage* ) imageWithColor: ( UIColor* )color
14 | {
15 | CGRect rect = CGRectMake( 0, 0, 1, 1 );
16 |
17 | UIGraphicsBeginImageContextWithOptions( rect.size, NO, 0 );
18 | [ color setFill ];
19 | UIRectFill( rect );
20 | UIImage* image = UIGraphicsGetImageFromCurrentImageContext( );
21 | UIGraphicsEndImageContext( );
22 |
23 | return image;
24 | }
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/UIImage+Resize.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Resize.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage ( Resize )
12 |
13 | -( UIImage* ) scaleToSize: ( CGSize )size;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/UIImage+Resize.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Resize.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "UIImage+Resize.h"
10 |
11 | @implementation UIImage ( Resize )
12 |
13 | -( UIImage* ) scaleToSize: ( CGSize )size
14 | {
15 | UIGraphicsBeginImageContext( size );
16 |
17 | CGContextRef context = UIGraphicsGetCurrentContext( );
18 | CGContextTranslateCTM( context, 0.0, size.height );
19 | CGContextScaleCTM( context, 1.0, -1.0 );
20 |
21 | CGContextDrawImage( context, CGRectMake( 0.0f, 0.0f, size.width, size.height ), self.CGImage );
22 |
23 | UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext( );
24 |
25 | UIGraphicsEndImageContext( );
26 |
27 | return scaledImage;
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/iosc.02-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/iosc.02-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_3_0
10 | #warning "This project uses features only available in iOS SDK 3.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02Tests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02Tests/iosc.02Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 5/iosc.02Tests/iosc_02Tests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iosc_02Tests.m
3 | // iosc.02Tests
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iosc_02Tests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iosc_02Tests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // IoscMapKit
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // IoscMapKit
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | #import "MapViewController.h"
12 |
13 | @implementation AppDelegate
14 |
15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
16 | {
17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
18 | // Override point for customization after application launch.
19 | self.window.backgroundColor = [UIColor whiteColor];
20 | [self.window makeKeyAndVisible];
21 |
22 | MapViewController* ctrl = [ [ [ MapViewController alloc ] initWithNibName: @"MapViewController" bundle: [ NSBundle mainBundle ] ] autorelease ];
23 | self.window.rootViewController = ctrl;
24 |
25 | return YES;
26 | }
27 |
28 | - (void)applicationWillResignActive:(UIApplication *)application
29 | {
30 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
31 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
32 | }
33 |
34 | - (void)applicationDidEnterBackground:(UIApplication *)application
35 | {
36 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
37 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
38 | }
39 |
40 | - (void)applicationWillEnterForeground:(UIApplication *)application
41 | {
42 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
43 | }
44 |
45 | - (void)applicationDidBecomeActive:(UIApplication *)application
46 | {
47 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
48 | }
49 |
50 | - (void)applicationWillTerminate:(UIApplication *)application
51 | {
52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
53 | }
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/CoordinateAnnotation.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoordinateAnnotation.h
3 | // IoscMapKit
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CoordinateAnnotation : NSObject< MKAnnotation >
12 |
13 | @property ( nonatomic, assign ) CLLocationCoordinate2D Coord;
14 | @property ( nonatomic, retain ) NSDate* Date;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/CoordinateAnnotation.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoordinateAnnotation.m
3 | // IoscMapKit
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "CoordinateAnnotation.h"
12 |
13 | @interface CoordinateAnnotation ( )
14 |
15 | @end
16 |
17 | @implementation CoordinateAnnotation
18 | {
19 | CLLocationCoordinate2D _coord;
20 | NSDate* _date;
21 | }
22 |
23 | @synthesize Coord = _coord;
24 | @synthesize Date = _date;
25 |
26 | -( CLLocationCoordinate2D ) coordinate
27 | {
28 | return _coord;
29 | }
30 |
31 | -( NSString* ) title
32 | {
33 | NSDateFormatter* fmt = [ NSDateFormatter new ];
34 | [ fmt setDateFormat: @"HH:mm:ss" ];
35 |
36 | return [ fmt stringFromDate: _date ];
37 | }
38 |
39 | -( id ) init
40 | {
41 | self = [ super init ];
42 | if ( nil != self )
43 | {
44 | }
45 |
46 | return self;
47 | }
48 |
49 | -( void ) dealloc
50 | {
51 | [ _date release ];
52 |
53 | [ super dealloc ];
54 | }
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "size" : "29x29",
21 | "scale" : "1x"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "size" : "29x29",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "size" : "40x40",
31 | "scale" : "1x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "40x40",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "76x76",
41 | "scale" : "1x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "76x76",
46 | "scale" : "2x"
47 | }
48 | ],
49 | "info" : {
50 | "version" : 1,
51 | "author" : "xcode"
52 | }
53 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/IoscMapKit-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/IoscMapKit-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_3_0
10 | #warning "This project uses features only available in iOS SDK 3.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/MapViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MapViewController.h
3 | // IoscMapKit
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MapViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/MapViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MapViewController.m
3 | // IoscMapKit
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | #import "MapViewController.h"
13 | #import "CoordinateAnnotation.h"
14 |
15 | @interface MapViewController ( ) < CLLocationManagerDelegate, MKMapViewDelegate >
16 |
17 | @property ( nonatomic, retain ) IBOutlet MKMapView* MapView;;
18 |
19 | @end
20 |
21 | @implementation MapViewController
22 | {
23 | MKMapView* _mapView;
24 |
25 | CLLocationManager* _locationManager;
26 | }
27 |
28 | @synthesize MapView = _mapView;
29 |
30 | -( id ) initWithNibName: ( NSString* )nibNameOrNil bundle: ( NSBundle* )nibBundleOrNil
31 | {
32 | self = [ super initWithNibName: nibNameOrNil bundle: nibBundleOrNil ];
33 | if ( self )
34 | {
35 | }
36 | return self;
37 | }
38 |
39 | -( void ) dealloc
40 | {
41 | [ _locationManager release ];
42 | [ _mapView release ];
43 |
44 | [ super dealloc ];
45 | }
46 |
47 | -( void ) viewDidLoad
48 | {
49 | [ super viewDidLoad ];
50 |
51 | if ( nil == _locationManager )
52 | _locationManager = [ [ CLLocationManager alloc ] init ];
53 |
54 | _locationManager.delegate = self;
55 | _locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
56 | _locationManager.distanceFilter = 1000;
57 | }
58 |
59 | -( void ) viewWillAppear: ( BOOL )animated
60 | {
61 | [ super viewWillAppear: animated ];
62 |
63 | [ _locationManager startUpdatingLocation ];
64 | }
65 |
66 | -( void ) viewWillDisappear: ( BOOL )animated
67 | {
68 | [ super viewWillDisappear: animated ];
69 |
70 | [ _locationManager stopUpdatingLocation ];
71 | }
72 |
73 |
74 | -( void ) didReceiveMemoryWarning
75 | {
76 | [ super didReceiveMemoryWarning ];
77 | }
78 |
79 | #pragma mark - CLLocationManagerDelegate
80 |
81 | -( void ) locationManager: ( CLLocationManager* )manager didUpdateToLocation: ( CLLocation* )newLocation fromLocation: ( CLLocation* )oldLocation
82 | {
83 | NSLog( @"new location: [ %f ; %f ]", newLocation.coordinate.latitude, newLocation.coordinate.longitude );
84 |
85 | CoordinateAnnotation* ann = [ [ [ CoordinateAnnotation alloc ] init ] autorelease ];
86 | ann.Coord = newLocation.coordinate;
87 | ann.Date = [ NSDate date ];
88 |
89 | [ _mapView addAnnotation: ann ];
90 | }
91 |
92 | #pragma mark - MKMapViewDelegate
93 |
94 | -( MKAnnotationView* ) mapView: ( MKMapView* )mapView viewForAnnotation: ( id< MKAnnotation > )annotation
95 | {
96 | MKAnnotationView* view = [ mapView dequeueReusableAnnotationViewWithIdentifier: @"annStyle" ];
97 | if ( nil == view )
98 | {
99 | view = [ [ [ MKPinAnnotationView alloc ] initWithAnnotation: annotation reuseIdentifier: @"annStyle" ] autorelease ];
100 | }
101 |
102 | view.annotation = annotation;
103 | view.canShowCallout = YES;
104 |
105 | return view;
106 | }
107 |
108 | @end
109 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/MapViewController.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKit/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // IoscMapKit
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKitTests/IoscMapKitTests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKitTests/IoscMapKitTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // IoscMapKitTests.m
3 | // IoscMapKitTests
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface IoscMapKitTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation IoscMapKitTests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6 (MapKit)/IoscMapKitTests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property ( nonatomic, retain ) UIWindow* Window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | #import "RSS.h"
12 | #import "RssItem.h"
13 | #import "RssChannel.h"
14 | #import "RssParser.h"
15 |
16 | #import "RssItemViewController.h"
17 | #import "RssChannelViewController.h"
18 |
19 | @interface AppDelegate ( ) < RssLoadingProtocol >
20 |
21 | -( void ) rssLoaded: ( RSS* )rss;
22 |
23 | @end
24 |
25 | @implementation AppDelegate
26 | {
27 | UIWindow* _window;
28 | RssChannelViewController* _ctrl;
29 | }
30 |
31 | -( void ) dealloc
32 | {
33 | [ _ctrl release ];
34 | [ _window release ];
35 |
36 | [ super dealloc ];
37 | }
38 |
39 | -( void ) rssLoaded: ( RSS* )rss
40 | {
41 | NSLog( @"RSS loaded (TS): %@", [ rss description ] );
42 | }
43 |
44 | -( void ) didSucceededLoadRSS: ( RSS* )rss
45 | {
46 | NSLog( @"RSS loaded (Prot): %@", [ rss description ] );
47 |
48 | _ctrl.Channel = [ rss.Channels objectAtIndex: 0 ];
49 | }
50 |
51 | -( void ) didRSSLoadFailed: ( NSError* )error
52 | {
53 | NSLog( @"RSS load failed: %@ [ %@ ] ", error, [ error userInfo ] );
54 | }
55 |
56 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
57 | {
58 | _window = [ [ UIWindow alloc ] initWithFrame: [ [ UIScreen mainScreen ] bounds ] ];
59 | _window.backgroundColor = [ UIColor whiteColor ];
60 |
61 | _ctrl = [ [ RssChannelViewController alloc ] initWithNibName: @"RssChannelViewController" bundle: [ NSBundle mainBundle ] ];
62 | [ RSS loadRssFromFile: @"file.sample.txt" target: self selector: @selector( rssLoaded: ) ];
63 | [ RSS loadRssFromFile: [ [ NSBundle mainBundle ] pathForResource: @"rss" ofType: @"xml" ] thenCallback: self ];
64 |
65 | UINavigationController* navctrl = [ [ [ UINavigationController alloc ] initWithRootViewController: _ctrl ] autorelease ];
66 | navctrl.navigationBar.barStyle = UIBarStyleBlackOpaque;
67 |
68 | _window.rootViewController = navctrl;
69 | [ _window makeKeyAndVisible ];
70 |
71 | /*
72 | RSS* rss = [ RSS sample ];
73 | NSLog( @"%@", [ rss description ] );
74 | */
75 |
76 | return YES;
77 | }
78 |
79 | - (void)applicationWillResignActive:(UIApplication *)application
80 | {
81 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
82 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
83 | }
84 |
85 | - (void)applicationDidEnterBackground:(UIApplication *)application
86 | {
87 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
88 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
89 | }
90 |
91 | - (void)applicationWillEnterForeground:(UIApplication *)application
92 | {
93 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
94 | }
95 |
96 | - (void)applicationDidBecomeActive:(UIApplication *)application
97 | {
98 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
99 | }
100 |
101 | - (void)applicationWillTerminate:(UIApplication *)application
102 | {
103 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
104 | }
105 |
106 | @end
107 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "size" : "29x29",
21 | "scale" : "1x"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "size" : "29x29",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "size" : "40x40",
31 | "scale" : "1x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "40x40",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "76x76",
41 | "scale" : "1x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "76x76",
46 | "scale" : "2x"
47 | }
48 | ],
49 | "info" : {
50 | "version" : 1,
51 | "author" : "xcode"
52 | }
53 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/NSString+Stripping.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+Stripping.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSString ( Stripping )
12 |
13 | -( NSString* ) stringByStrippingHTML;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/NSString+Stripping.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+Stripping.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "NSString+Stripping.h"
10 |
11 | @implementation NSString ( Stripping )
12 |
13 | -( NSString* ) stringByStrippingHTML
14 | {
15 | NSRange r;
16 | NSString* s = [ [ self copy ] autorelease ];
17 | while ( ( r = [ s rangeOfString: @"<[^>]+>" options: NSRegularExpressionSearch ] ).location != NSNotFound )
18 | s = [ s stringByReplacingCharactersInRange:r withString: @"" ];
19 | return s;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RSS.h:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RSS;
12 |
13 | @protocol RssLoadingProtocol
14 |
15 | -( void ) didSucceededLoadRSS: ( RSS* )rss;
16 | -( void ) didRSSLoadFailed: ( NSError* )error;
17 |
18 | @end
19 |
20 | @interface RSS : NSObject
21 |
22 | @property ( nonatomic, retain ) NSArray* Channels;
23 |
24 | +( RSS* ) sample;
25 |
26 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector;
27 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RSS.m:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RSS.h"
10 | #import "RssChannel.h"
11 | #import "RssItem.h"
12 |
13 | #import "RssParser.h"
14 |
15 | @implementation RSS
16 | {
17 | NSArray* _channels;
18 | }
19 |
20 | @synthesize Channels = _channels;
21 |
22 | -( id ) init
23 | {
24 | self = [ super init ];
25 |
26 | if ( nil != self )
27 | {
28 | // TODO:
29 | }
30 |
31 | return self;
32 | }
33 |
34 | -( void ) dealloc
35 | {
36 | [ _channels release ];
37 |
38 | [ super dealloc ];
39 | }
40 |
41 | -( NSString* ) description
42 | {
43 | NSMutableString* str = [ NSMutableString string ];
44 |
45 | [ str appendFormat: @"Channels:\n" ];
46 |
47 | for ( RssChannel* ch in _channels )
48 | {
49 | [ str appendFormat: @"%@\n", [ ch description ] ];
50 | }
51 |
52 | return [ NSString stringWithString: str ];
53 | }
54 |
55 | #pragma mark - public routines
56 |
57 | +( RSS* ) sample
58 | {
59 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
60 |
61 | RssChannel* ch = [ RssChannel sampleChannel ];
62 |
63 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
64 |
65 | return rss;
66 | }
67 |
68 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector
69 | {
70 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
71 | RssChannel* ch = [ RssChannel sampleChannel ];
72 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
73 |
74 | if ( [ target respondsToSelector: selector ] )
75 | [ target performSelector: selector withObject: rss ];
76 | }
77 |
78 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback
79 | {
80 | RssParser* parser = [ [ [ RssParser alloc ] init ] autorelease ];
81 | RSS* rss = [ parser parseRssFeedFromFile: fileName ];
82 |
83 | if ( nil != callback )
84 | [ callback didSucceededLoadRSS: rss ];
85 | }
86 |
87 |
88 | @end
89 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssChannel.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssChannel : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* Link;
15 | @property ( nonatomic, copy ) NSString* Desc;
16 | @property ( nonatomic, retain ) NSArray* Items;
17 |
18 | +( RssChannel* ) sampleChannel;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssChannel.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 | #import "RssChannel.h"
11 |
12 | @implementation RssChannel
13 | {
14 | NSString* _title;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSArray* _items;
18 | }
19 |
20 | @synthesize Title = _title;
21 | @synthesize Link = _link;
22 | @synthesize Desc = _desc;
23 | @synthesize Items = _items;
24 |
25 | -( id ) init
26 | {
27 | self = [ super init ];
28 |
29 | if ( nil != self )
30 | {
31 | // TODO:
32 | }
33 |
34 | return self;
35 | }
36 |
37 | -( void ) dealloc
38 | {
39 | [ _title release ];
40 | [ _link release ];
41 | [ _desc release ];
42 | [ _items release ];
43 |
44 | [ super dealloc ];
45 | }
46 |
47 | -( NSString* ) description
48 | {
49 | NSMutableString* str = [ NSMutableString string ];
50 |
51 | [ str appendFormat: @"\tTitle: %@\n", _title ];
52 | [ str appendFormat: @"\tLink: %@\n", _link ];
53 | [ str appendFormat: @"\tDesc: %@\n", _desc ];
54 | [ str appendFormat: @"\tItems:\n" ];
55 |
56 | for ( RssItem* item in _items )
57 | {
58 | [ str appendFormat: @"%@\n", [ item description ] ];
59 | }
60 |
61 | return [ NSString stringWithString: str ];
62 | }
63 |
64 | #pragma mark - public routines
65 |
66 | +( RssChannel* ) sampleChannel
67 | {
68 | RssChannel* ch = [ [ [ RssChannel alloc] init ] autorelease ];
69 |
70 | ch.Title = @"it works!";
71 | ch.Link = @"http://itw66.ru";
72 | ch.Desc = @"it works! / RSS channel";
73 |
74 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
75 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
76 |
77 | RssItem* item = [ [ [ RssItem alloc ] init ] autorelease ];
78 | item.Title = @"Персональный батискаф";
79 | item.GUID = @"http://itw66.ru/blog/interesting_things/743.html";
80 | item.Link = @"http://itw66.ru/blog/interesting_things/743.html";
81 | item.Desc = @" Жак=Ив Кусто, один из создателей акваланга, является одним из самых известных исследователей морей и океанов. Всем хорошо известна «Подводная одиссея команды Кусто». Кроме того, один из его первых цветных подводных фильмов был удостоен Пальмовой Ветви в Каннах в 1956 году. Кусто успел повидать и поведать нам о многом, но несмотря на это морское дно хранит еще много тайн о жизни на Земле. С начала исследований морского дна и во многом благодаря им были сделаны существенные технологические и экологические открытия. Совсем недавно, в 2010 году, в своей речи на событии Mission Blue, организованном TED, океанограф Эдит Виддер (Edith Widder) говорила об исследовании водной части Земли и заметила, что в исследование морских глубин денег вкладывается гораздо меньше, чем например в исследовании космоса, хотя на данный момент всего около 5% океанов исследовано человеком. Она также заметила, что исследования — это сила, которая движет инновациями. Ее призыв услышал дизайнер Эдуардо Гальвани (Eduardo Galvani), который предложил проект персонального батискафа — Manatee, для создания возможности персонального изучения морских глубин.подробности... ";
82 | item.PubDate = [ fmt dateFromString: @"Thu, 03 Jul 2014 12:56:57 +0400" ];
83 | item.Categories = [ NSArray arrayWithObjects: @"батискаф", @"персональный", @"manatee", @"Eduardo Galvani", nil ];
84 |
85 | RssItem* item2 = [ [ [ RssItem alloc ] init ] autorelease ];
86 | item2.Title = @"Новый взгляд на ветряную турбину!";
87 | item2.GUID = @"http://itw66.ru/blog/alternative_energy/742.html";
88 | item2.Link = @"http://itw66.ru/blog/alternative_energy/742.html";
89 | item2.Desc = @"img src=\"http://itw66.ru/uploads/images/00/00/01/2014/06/23/2f7842.jpg\"/> Все мы уже привыкли к традиционным формам ветряков, которые конструкцию свою получили от достаточно древних ветряных мельниц. У них есть как свои плюсы, так и свои минусы. Специалисты из компании Solar Wind Energy Inc. задумались над тем, как решить проблему отсутствия ветра, а заодно и повышения КПД устройства. В итоге они изобрели Solar Wind Downdraft Tower, башню, которая для генерации электричества может создавать свой собственный ветер. Как это может работать? Читайте далее…а вот как... ";
90 | item2.PubDate = [ fmt dateFromString: @"Mon, 23 Jun 2014 21:45:20 +0400" ];
91 | item2.Categories = [ NSArray arrayWithObjects: @"Solar Wind Energy Inc", @"Downdraft Tower", @"башня-ветряк", nil ];
92 |
93 | ch.Items = [ NSArray arrayWithObjects: item, item2, nil ];
94 |
95 | return ch;
96 | }
97 |
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssChannelViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannelViewController.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RssChannel;
12 |
13 | @interface RssChannelViewController : UIViewController
14 |
15 | @property ( nonatomic, retain ) RssChannel* Channel;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssChannelViewController.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssItem : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* GUID;
15 | @property ( nonatomic, copy ) NSString* Link;
16 | @property ( nonatomic, copy ) NSString* Desc;
17 | @property ( nonatomic, retain ) NSDate* PubDate;
18 | @property ( nonatomic, retain ) NSArray* Categories;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssItem.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 |
11 | @implementation RssItem
12 | {
13 | NSString* _title;
14 | NSString* _guid;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSDate* _pubDate;
18 | NSArray* _categories;
19 | }
20 |
21 | @synthesize Title = _title;
22 | @synthesize GUID = _guid;
23 | @synthesize Link = _link;
24 | @synthesize Desc = _desc;
25 | @synthesize PubDate = _pubDate;
26 | @synthesize Categories = _categories;
27 |
28 | -( id ) init
29 | {
30 | self = [ super init ];
31 |
32 | if ( nil != self )
33 | {
34 | // TODO:
35 | }
36 |
37 | return self;
38 | }
39 |
40 | -( void ) dealloc
41 | {
42 | [ _title release ];
43 | [ _guid release ];
44 | [ _link release ];
45 | [ _desc release ];
46 | [ _pubDate release ];
47 | [ _categories release ];
48 |
49 | [ super dealloc ];
50 | }
51 |
52 | -( NSString* ) description
53 | {
54 | NSMutableString* str = [ NSMutableString string ];
55 |
56 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
57 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
58 |
59 | [ str appendFormat: @"\t\tTitle: %@\n", _title ];
60 | [ str appendFormat: @"\t\tGUID: %@\n", _guid ];
61 | [ str appendFormat: @"\t\tLink: %@\n", _link ];
62 | [ str appendFormat: @"\t\tDesc: %@\n", _desc ];
63 | [ str appendFormat: @"\t\tPubDate: %@\n", [ fmt stringFromDate: _pubDate ] ];
64 | [ str appendFormat: @"\t\tCategories: " ];
65 |
66 | for ( NSString* cat in _categories )
67 | {
68 | [ str appendFormat: @"%@, ", cat ];
69 | }
70 | [ str appendFormat: @"\n" ];
71 |
72 | return [ NSString stringWithString: str ];
73 | }
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssItemCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemCell.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssItemCell : UITableViewCell
12 |
13 | @property ( nonatomic, retain ) IBOutlet UIImageView* ImageView;
14 | @property ( nonatomic, retain ) IBOutlet UILabel* Title;
15 | @property ( nonatomic, retain ) IBOutlet UILabel* Desc;
16 | @property ( nonatomic, retain ) IBOutlet UILabel* Date;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssItemCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemCell.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItemCell.h"
10 |
11 | @implementation RssItemCell
12 | {
13 | UIImageView* _imageView;
14 | UILabel* _title;
15 | UILabel* _desc;
16 | UILabel* _date;
17 | }
18 |
19 | @synthesize ImageView = _imageView;
20 | @synthesize Title = _title;
21 | @synthesize Desc = _desc;
22 | @synthesize Date = _date;
23 |
24 | -( id ) initWithStyle: ( UITableViewCellStyle )style reuseIdentifier: ( NSString* )reuseIdentifier
25 | {
26 | self = [ super initWithStyle: style reuseIdentifier: reuseIdentifier ];
27 | if ( self )
28 | {
29 | }
30 |
31 | return self;
32 | }
33 |
34 | -( void ) dealloc
35 | {
36 | [ _imageView release ];
37 | [ _title release ];
38 | [ _desc release ];
39 | [ _date release ];
40 |
41 | [ super dealloc ];
42 | }
43 |
44 | -( void ) awakeFromNib
45 | {
46 | }
47 |
48 | -( void ) setSelected: ( BOOL )selected animated: ( BOOL )animated
49 | {
50 | [ super setSelected: selected animated: animated ];
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssItemCell.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssItemViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemViewController.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RssItem;
12 |
13 | @interface RssItemViewController : UIViewController
14 |
15 | @property ( nonatomic, retain ) RssItem* Item;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssItemViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemViewController.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItemViewController.h"
10 |
11 | #import "RssItem.h"
12 |
13 | @interface RssItemViewController ( )
14 |
15 | @property ( nonatomic, retain ) IBOutlet UIImageView* ImageView;
16 | @property ( nonatomic, retain ) IBOutlet UILabel* TitleView;
17 | @property ( nonatomic, retain ) IBOutlet UIWebView* DescriptionView;
18 |
19 | @end
20 |
21 | @implementation RssItemViewController
22 | {
23 | UIImageView* _imageView;
24 | UILabel* _titleView;
25 | UIWebView* _descriptionView;
26 |
27 | RssItem* _item;
28 | }
29 |
30 | @synthesize ImageView = _imageView;
31 | @synthesize TitleView = _titleView;
32 | @synthesize DescriptionView = _descriptionView;
33 |
34 | @synthesize Item = _item;
35 |
36 | -( id ) initWithNibName: ( NSString* )nibNameOrNil bundle: ( NSBundle* )nibBundleOrNil
37 | {
38 | self = [ super initWithNibName: nibNameOrNil bundle: nibBundleOrNil ];
39 |
40 | if ( nil != self )
41 | {
42 | }
43 |
44 | return self;
45 | }
46 |
47 | -( void ) dealloc
48 | {
49 | [ _imageView release ];
50 | [ _titleView release ];
51 | [ _descriptionView release ];
52 |
53 | [ _item release ];
54 |
55 | [ super dealloc ];
56 | }
57 |
58 | -( void ) viewDidLoad
59 | {
60 | [ super viewDidLoad ];
61 |
62 | self.edgesForExtendedLayout = UIRectEdgeNone;
63 |
64 | _titleView.text = @"";
65 | [ _descriptionView loadHTMLString: @"" baseURL: nil ];
66 | }
67 |
68 | -( void ) viewDidAppear: ( BOOL )animated
69 | {
70 | [ super viewDidAppear: animated ];
71 |
72 | [ self setItem: _item ];
73 | }
74 |
75 | -( void ) viewWillAppear: ( BOOL )animated
76 | {
77 | [ super viewWillAppear: animated ];
78 |
79 | self.navigationItem.title = _item.Title;
80 | self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
81 | }
82 |
83 | -( void ) didReceiveMemoryWarning
84 | {
85 | [ super didReceiveMemoryWarning ];
86 | }
87 |
88 | #pragma mark - public routines
89 |
90 | -( void ) setItem: ( RssItem* )item
91 | {
92 | [ _item release ];
93 | _item = [ item retain ];
94 |
95 | _titleView.text = item.Title;
96 | [ _descriptionView loadHTMLString: item.Desc baseURL: nil ];
97 |
98 | NSDataDetector* detector = [ NSDataDetector dataDetectorWithTypes: NSTextCheckingTypeLink error: nil ];
99 | NSArray* matches = [ detector matchesInString: item.Desc options: 0 range: NSMakeRange( 0, [ item.Desc length ] ) ];
100 | if ( [ matches count ] > 0 )
101 | {
102 | NSTextCheckingResult* match = [ matches objectAtIndex: 0 ];
103 | if ( [ match resultType ] == NSTextCheckingTypeLink )
104 | {
105 | NSURL* url = [ match URL ];
106 | NSData* data = [ NSData dataWithContentsOfURL: url ];
107 | UIImage* img = [ UIImage imageWithData: data ];
108 | _imageView.image = img;
109 | }
110 | else
111 | {
112 | _imageView.image = nil;
113 | }
114 | }
115 | else
116 | {
117 | _imageView.image = nil;
118 | }
119 | }
120 |
121 |
122 | @end
123 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssItemViewController.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/RssParser.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssParser.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 14/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RSS.h"
12 |
13 | @interface RssParser : NSObject
14 |
15 | -( RSS* ) parseRssFeedFromFile: ( NSString* )filePath;
16 | -( RSS* ) parseRssFeedFromData: ( NSData* )data;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/UIImage+Colored.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Colored.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage ( Colored )
12 |
13 | +( UIImage* ) imageWithColor: ( UIColor* )color;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/UIImage+Colored.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Colored.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "UIImage+Colored.h"
10 |
11 | @implementation UIImage ( Colored )
12 |
13 | +( UIImage* ) imageWithColor: ( UIColor* )color
14 | {
15 | CGRect rect = CGRectMake( 0, 0, 1, 1 );
16 |
17 | UIGraphicsBeginImageContextWithOptions( rect.size, NO, 0 );
18 | [ color setFill ];
19 | UIRectFill( rect );
20 | UIImage* image = UIGraphicsGetImageFromCurrentImageContext( );
21 | UIGraphicsEndImageContext( );
22 |
23 | return image;
24 | }
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/UIImage+Resize.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Resize.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage ( Resize )
12 |
13 | -( UIImage* ) scaleToSize: ( CGSize )size;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/UIImage+Resize.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Resize.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "UIImage+Resize.h"
10 |
11 | @implementation UIImage ( Resize )
12 |
13 | -( UIImage* ) scaleToSize: ( CGSize )size
14 | {
15 | UIGraphicsBeginImageContext( size );
16 |
17 | CGContextRef context = UIGraphicsGetCurrentContext( );
18 | CGContextTranslateCTM( context, 0.0, size.height );
19 | CGContextScaleCTM( context, 1.0, -1.0 );
20 |
21 | CGContextDrawImage( context, CGRectMake( 0.0f, 0.0f, size.width, size.height ), self.CGImage );
22 |
23 | UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext( );
24 |
25 | UIGraphicsEndImageContext( );
26 |
27 | return scaledImage;
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/iosc.02-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/iosc.02-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_3_0
10 | #warning "This project uses features only available in iOS SDK 3.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02Tests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02Tests/iosc.02Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 6/iosc.02Tests/iosc_02Tests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iosc_02Tests.m
3 | // iosc.02Tests
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iosc_02Tests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iosc_02Tests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property ( nonatomic, retain ) UIWindow* Window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | #import "RSS.h"
12 | #import "RssItem.h"
13 | #import "RssChannel.h"
14 | #import "RssParser.h"
15 |
16 | #import "RssItemViewController.h"
17 | #import "RssChannelViewController.h"
18 |
19 | @interface AppDelegate ( ) < RssLoadingProtocol >
20 |
21 | -( void ) rssLoaded: ( RSS* )rss;
22 |
23 | @end
24 |
25 | @implementation AppDelegate
26 | {
27 | UIWindow* _window;
28 | RssChannelViewController* _ctrl;
29 | }
30 |
31 | -( void ) dealloc
32 | {
33 | [ _ctrl release ];
34 | [ _window release ];
35 |
36 | [ super dealloc ];
37 | }
38 |
39 | -( void ) rssLoaded: ( RSS* )rss
40 | {
41 | NSLog( @"RSS loaded (TS): %@", [ rss description ] );
42 | }
43 |
44 | -( void ) didSucceededLoadRSS: ( RSS* )rss
45 | {
46 | NSLog( @"RSS loaded (Prot): %@", [ rss description ] );
47 |
48 | _ctrl.Channel = [ rss.Channels objectAtIndex: 0 ];
49 | }
50 |
51 | -( void ) didRSSLoadFailed: ( NSError* )error
52 | {
53 | NSLog( @"RSS load failed: %@ [ %@ ] ", error, [ error userInfo ] );
54 | }
55 |
56 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
57 | {
58 | _window = [ [ UIWindow alloc ] initWithFrame: [ [ UIScreen mainScreen ] bounds ] ];
59 | _window.backgroundColor = [ UIColor whiteColor ];
60 |
61 | _ctrl = [ [ RssChannelViewController alloc ] initWithNibName: @"RssChannelViewController" bundle: [ NSBundle mainBundle ] ];
62 | // [ RSS loadRssFromFile: @"file.sample.txt" target: self selector: @selector( rssLoaded: ) ];
63 | // [ RSS loadRssFromFile: [ [ NSBundle mainBundle ] pathForResource: @"rss" ofType: @"xml" ] thenCallback: self ];
64 |
65 | UINavigationController* navctrl = [ [ [ UINavigationController alloc ] initWithRootViewController: _ctrl ] autorelease ];
66 | navctrl.navigationBar.barStyle = UIBarStyleBlackOpaque;
67 |
68 | _window.rootViewController = navctrl;
69 | [ _window makeKeyAndVisible ];
70 |
71 | /*
72 | RSS* rss = [ RSS sample ];
73 | NSLog( @"%@", [ rss description ] );
74 | */
75 |
76 | return YES;
77 | }
78 |
79 | - (void)applicationWillResignActive:(UIApplication *)application
80 | {
81 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
82 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
83 | }
84 |
85 | - (void)applicationDidEnterBackground:(UIApplication *)application
86 | {
87 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
88 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
89 | }
90 |
91 | - (void)applicationWillEnterForeground:(UIApplication *)application
92 | {
93 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
94 | }
95 |
96 | - (void)applicationDidBecomeActive:(UIApplication *)application
97 | {
98 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
99 | }
100 |
101 | - (void)applicationWillTerminate:(UIApplication *)application
102 | {
103 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
104 | }
105 |
106 | @end
107 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "size" : "29x29",
21 | "scale" : "1x"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "size" : "29x29",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "size" : "40x40",
31 | "scale" : "1x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "40x40",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "76x76",
41 | "scale" : "1x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "76x76",
46 | "scale" : "2x"
47 | }
48 | ],
49 | "info" : {
50 | "version" : 1,
51 | "author" : "xcode"
52 | }
53 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/NSString+Stripping.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+Stripping.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSString ( Stripping )
12 |
13 | -( NSString* ) stringByStrippingHTML;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/NSString+Stripping.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+Stripping.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "NSString+Stripping.h"
10 |
11 | @implementation NSString ( Stripping )
12 |
13 | -( NSString* ) stringByStrippingHTML
14 | {
15 | NSRange r;
16 | NSString* s = [ [ self copy ] autorelease ];
17 | while ( ( r = [ s rangeOfString: @"<[^>]+>" options: NSRegularExpressionSearch ] ).location != NSNotFound )
18 | s = [ s stringByReplacingCharactersInRange:r withString: @"" ];
19 | return s;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RSS.h:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RSS;
12 |
13 | @protocol RssLoadingProtocol
14 |
15 | -( void ) didSucceededLoadRSS: ( RSS* )rss;
16 | -( void ) didRSSLoadFailed: ( NSError* )error;
17 |
18 | @end
19 |
20 | @interface RSS : NSObject
21 |
22 | @property ( nonatomic, retain ) NSArray* Channels;
23 |
24 | +( RSS* ) sample;
25 |
26 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector;
27 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback;
28 | +( void ) loadRssFromURL: ( NSURL* )url thenCallback: ( id< RssLoadingProtocol > )callback;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RSS.m:
--------------------------------------------------------------------------------
1 | //
2 | // RSS.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RSS.h"
10 | #import "RssChannel.h"
11 | #import "RssItem.h"
12 |
13 | #import "RssParser.h"
14 |
15 | @implementation RSS
16 | {
17 | NSArray* _channels;
18 | }
19 |
20 | @synthesize Channels = _channels;
21 |
22 | -( id ) init
23 | {
24 | self = [ super init ];
25 |
26 | if ( nil != self )
27 | {
28 | // TODO:
29 | }
30 |
31 | return self;
32 | }
33 |
34 | -( void ) dealloc
35 | {
36 | [ _channels release ];
37 |
38 | [ super dealloc ];
39 | }
40 |
41 | -( NSString* ) description
42 | {
43 | NSMutableString* str = [ NSMutableString string ];
44 |
45 | [ str appendFormat: @"Channels:\n" ];
46 |
47 | for ( RssChannel* ch in _channels )
48 | {
49 | [ str appendFormat: @"%@\n", [ ch description ] ];
50 | }
51 |
52 | return [ NSString stringWithString: str ];
53 | }
54 |
55 | #pragma mark - public routines
56 |
57 | +( RSS* ) sample
58 | {
59 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
60 |
61 | RssChannel* ch = [ RssChannel sampleChannel ];
62 |
63 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
64 |
65 | return rss;
66 | }
67 |
68 | +( void ) loadRssFromFile: ( NSString* )fileName target: ( id )target selector: ( SEL )selector
69 | {
70 | RSS* rss = [ [ [ RSS alloc ] init ] autorelease ];
71 | RssChannel* ch = [ RssChannel sampleChannel ];
72 | rss.Channels = [ NSArray arrayWithObjects: ch, nil ];
73 |
74 | if ( [ target respondsToSelector: selector ] )
75 | [ target performSelector: selector withObject: rss ];
76 | }
77 |
78 | +( void ) loadRssFromFile: ( NSString* )fileName thenCallback: ( id< RssLoadingProtocol > )callback
79 | {
80 | RssParser* parser = [ [ [ RssParser alloc ] init ] autorelease ];
81 | RSS* rss = [ parser parseRssFeedFromFile: fileName ];
82 |
83 | if ( nil != callback )
84 | [ callback didSucceededLoadRSS: rss ];
85 | }
86 |
87 | +( void ) loadRssFromURL: ( NSURL* )url thenCallback: ( id< RssLoadingProtocol > )callback
88 | {
89 |
90 | }
91 |
92 |
93 | @end
94 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssChannel.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannel.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssChannel : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* Link;
15 | @property ( nonatomic, copy ) NSString* Desc;
16 | @property ( nonatomic, retain ) NSArray* Items;
17 |
18 | +( RssChannel* ) sampleChannel;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssChannelViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssChannelViewController.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RssChannel;
12 |
13 | @interface RssChannelViewController : UIViewController
14 |
15 | @property ( nonatomic, retain ) RssChannel* Channel;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssChannelViewController.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssItem : NSObject
12 |
13 | @property ( nonatomic, copy ) NSString* Title;
14 | @property ( nonatomic, copy ) NSString* GUID;
15 | @property ( nonatomic, copy ) NSString* Link;
16 | @property ( nonatomic, copy ) NSString* Desc;
17 | @property ( nonatomic, retain ) NSDate* PubDate;
18 | @property ( nonatomic, retain ) NSArray* Categories;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssItem.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItem.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItem.h"
10 |
11 | @implementation RssItem
12 | {
13 | NSString* _title;
14 | NSString* _guid;
15 | NSString* _link;
16 | NSString* _desc;
17 | NSDate* _pubDate;
18 | NSArray* _categories;
19 | }
20 |
21 | @synthesize Title = _title;
22 | @synthesize GUID = _guid;
23 | @synthesize Link = _link;
24 | @synthesize Desc = _desc;
25 | @synthesize PubDate = _pubDate;
26 | @synthesize Categories = _categories;
27 |
28 | -( id ) init
29 | {
30 | self = [ super init ];
31 |
32 | if ( nil != self )
33 | {
34 | // TODO:
35 | }
36 |
37 | return self;
38 | }
39 |
40 | -( void ) dealloc
41 | {
42 | [ _title release ];
43 | [ _guid release ];
44 | [ _link release ];
45 | [ _desc release ];
46 | [ _pubDate release ];
47 | [ _categories release ];
48 |
49 | [ super dealloc ];
50 | }
51 |
52 | -( NSString* ) description
53 | {
54 | NSMutableString* str = [ NSMutableString string ];
55 |
56 | NSDateFormatter* fmt = [ [ [ NSDateFormatter alloc ] init ] autorelease ];
57 | [ fmt setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss z" ];
58 |
59 | [ str appendFormat: @"\t\tTitle: %@\n", _title ];
60 | [ str appendFormat: @"\t\tGUID: %@\n", _guid ];
61 | [ str appendFormat: @"\t\tLink: %@\n", _link ];
62 | [ str appendFormat: @"\t\tDesc: %@\n", _desc ];
63 | [ str appendFormat: @"\t\tPubDate: %@\n", [ fmt stringFromDate: _pubDate ] ];
64 | [ str appendFormat: @"\t\tCategories: " ];
65 |
66 | for ( NSString* cat in _categories )
67 | {
68 | [ str appendFormat: @"%@, ", cat ];
69 | }
70 | [ str appendFormat: @"\n" ];
71 |
72 | return [ NSString stringWithString: str ];
73 | }
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssItemCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemCell.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssItemCell : UITableViewCell
12 |
13 | @property ( nonatomic, retain ) IBOutlet UIImageView* ImageView;
14 | @property ( nonatomic, retain ) IBOutlet UILabel* Title;
15 | @property ( nonatomic, retain ) IBOutlet UILabel* Desc;
16 | @property ( nonatomic, retain ) IBOutlet UILabel* Date;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssItemCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemCell.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItemCell.h"
10 |
11 | @implementation RssItemCell
12 | {
13 | UIImageView* _imageView;
14 | UILabel* _title;
15 | UILabel* _desc;
16 | UILabel* _date;
17 | }
18 |
19 | @synthesize ImageView = _imageView;
20 | @synthesize Title = _title;
21 | @synthesize Desc = _desc;
22 | @synthesize Date = _date;
23 |
24 | -( id ) initWithStyle: ( UITableViewCellStyle )style reuseIdentifier: ( NSString* )reuseIdentifier
25 | {
26 | self = [ super initWithStyle: style reuseIdentifier: reuseIdentifier ];
27 | if ( self )
28 | {
29 | }
30 |
31 | return self;
32 | }
33 |
34 | -( void ) dealloc
35 | {
36 | [ _imageView release ];
37 | [ _title release ];
38 | [ _desc release ];
39 | [ _date release ];
40 |
41 | [ super dealloc ];
42 | }
43 |
44 | -( void ) awakeFromNib
45 | {
46 | }
47 |
48 | -( void ) setSelected: ( BOOL )selected animated: ( BOOL )animated
49 | {
50 | [ super setSelected: selected animated: animated ];
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssItemCell.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssItemViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemViewController.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class RssItem;
12 |
13 | @interface RssItemViewController : UIViewController
14 |
15 | @property ( nonatomic, retain ) RssItem* Item;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssItemViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssItemViewController.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssItemViewController.h"
10 |
11 | #import "RssItem.h"
12 |
13 | @interface RssItemViewController ( )
14 |
15 | @property ( nonatomic, retain ) IBOutlet UIImageView* ImageView;
16 | @property ( nonatomic, retain ) IBOutlet UILabel* TitleView;
17 | @property ( nonatomic, retain ) IBOutlet UIWebView* DescriptionView;
18 |
19 | @end
20 |
21 | @implementation RssItemViewController
22 | {
23 | UIImageView* _imageView;
24 | UILabel* _titleView;
25 | UIWebView* _descriptionView;
26 |
27 | RssItem* _item;
28 | }
29 |
30 | @synthesize ImageView = _imageView;
31 | @synthesize TitleView = _titleView;
32 | @synthesize DescriptionView = _descriptionView;
33 |
34 | @synthesize Item = _item;
35 |
36 | -( id ) initWithNibName: ( NSString* )nibNameOrNil bundle: ( NSBundle* )nibBundleOrNil
37 | {
38 | self = [ super initWithNibName: nibNameOrNil bundle: nibBundleOrNil ];
39 |
40 | if ( nil != self )
41 | {
42 | }
43 |
44 | return self;
45 | }
46 |
47 | -( void ) dealloc
48 | {
49 | [ _imageView release ];
50 | [ _titleView release ];
51 | [ _descriptionView release ];
52 |
53 | [ _item release ];
54 |
55 | [ super dealloc ];
56 | }
57 |
58 | -( void ) viewDidLoad
59 | {
60 | [ super viewDidLoad ];
61 |
62 | self.edgesForExtendedLayout = UIRectEdgeNone;
63 |
64 | _titleView.text = @"";
65 | [ _descriptionView loadHTMLString: @"" baseURL: nil ];
66 | }
67 |
68 | -( void ) viewDidAppear: ( BOOL )animated
69 | {
70 | [ super viewDidAppear: animated ];
71 |
72 | [ self setItem: _item ];
73 | }
74 |
75 | -( void ) viewWillAppear: ( BOOL )animated
76 | {
77 | [ super viewWillAppear: animated ];
78 |
79 | self.navigationItem.title = _item.Title;
80 | self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
81 | }
82 |
83 | -( void ) didReceiveMemoryWarning
84 | {
85 | [ super didReceiveMemoryWarning ];
86 | }
87 |
88 | #pragma mark - public routines
89 |
90 | -( void ) setItem: ( RssItem* )item
91 | {
92 | [ _item release ];
93 | _item = [ item retain ];
94 |
95 | _titleView.text = item.Title;
96 | [ _descriptionView loadHTMLString: item.Desc baseURL: nil ];
97 |
98 | NSDataDetector* detector = [ NSDataDetector dataDetectorWithTypes: NSTextCheckingTypeLink error: nil ];
99 | NSArray* matches = [ detector matchesInString: item.Desc options: 0 range: NSMakeRange( 0, [ item.Desc length ] ) ];
100 | if ( [ matches count ] > 0 )
101 | {
102 | NSTextCheckingResult* match = [ matches objectAtIndex: 0 ];
103 | if ( [ match resultType ] == NSTextCheckingTypeLink )
104 | {
105 | NSURL* url = [ match URL ];
106 | NSData* data = [ NSData dataWithContentsOfURL: url ];
107 | UIImage* img = [ UIImage imageWithData: data ];
108 | _imageView.image = img;
109 | }
110 | else
111 | {
112 | _imageView.image = nil;
113 | }
114 | }
115 | else
116 | {
117 | _imageView.image = nil;
118 | }
119 | }
120 |
121 |
122 | @end
123 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssItemViewController.xib:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssLoader.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssLoader.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RssLoader : NSObject
12 |
13 | -( id ) initWithURL: ( NSURL* )url thenCallTarget: ( id )target withSelector: ( SEL )selector;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssLoader.m:
--------------------------------------------------------------------------------
1 | //
2 | // RssLoader.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/08/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "RssLoader.h"
10 | #import "RssParser.h"
11 |
12 | @interface RssLoader ( ) < NSURLConnectionDataDelegate, NSURLConnectionDelegate >
13 |
14 | @end
15 |
16 | @implementation RssLoader
17 | {
18 | NSMutableData* _data;
19 | NSURLConnection* _connection;
20 |
21 | id _target;
22 | SEL _selector;
23 | }
24 |
25 | #pragma mark - NSURLConnectionDataDelegate
26 |
27 | -( id ) initWithURL: ( NSURL* )url thenCallTarget: ( id )target withSelector: ( SEL )selector;
28 | {
29 | self = [ super init ];
30 | if ( nil != self )
31 | {
32 | _data = [ [ NSMutableData alloc ] init ];
33 | _target = target;
34 | _selector = selector;
35 |
36 | NSMutableURLRequest* req = [ [ [ NSMutableURLRequest alloc ] initWithURL: url ] autorelease ];
37 | [ req setHTTPMethod: @"GET" ];
38 | [ req setCachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData ];
39 |
40 | _connection = [ [ NSURLConnection connectionWithRequest: req delegate: self ] retain ];
41 | }
42 |
43 | return self;
44 | }
45 |
46 | -( void ) dealloc
47 | {
48 | [ _data release ];
49 | [ _connection release ];
50 |
51 | [ super dealloc ];
52 | }
53 |
54 | -( void ) connection: ( NSURLConnection* )connection didReceiveResponse: ( NSURLResponse* )response
55 | {
56 | [ _data setLength: 0 ];
57 | }
58 |
59 | -( void ) connection: ( NSURLConnection* )connection didReceiveData: ( NSData* )data
60 | {
61 | [ _data appendData: data ];
62 | }
63 |
64 | -( void ) connectionDidFinishLoading: ( NSURLConnection* )connection
65 | {
66 | RssParser* parser = [ [ [ RssParser alloc ] init ] autorelease ];
67 | RSS* rss = [ parser parseRssFeedFromData: _data ];
68 |
69 | [ _target performSelector: _selector withObject: rss ];
70 | [ self autorelease ];
71 | }
72 |
73 | #pragma mark - NSURLConnectionDelegate
74 |
75 | -( void ) connection: ( NSURLConnection* )connection didFailWithError: ( NSError* )error
76 | {
77 | [ _target performSelector: _selector withObject: error ];
78 | [ self autorelease ];
79 | }
80 |
81 | @end
82 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/RssParser.h:
--------------------------------------------------------------------------------
1 | //
2 | // RssParser.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 14/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RSS.h"
12 |
13 | @interface RssParser : NSObject
14 |
15 | -( RSS* ) parseRssFeedFromFile: ( NSString* )filePath;
16 | -( RSS* ) parseRssFeedFromData: ( NSData* )data;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/UIImage+Colored.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Colored.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage ( Colored )
12 |
13 | +( UIImage* ) imageWithColor: ( UIColor* )color;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/UIImage+Colored.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Colored.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "UIImage+Colored.h"
10 |
11 | @implementation UIImage ( Colored )
12 |
13 | +( UIImage* ) imageWithColor: ( UIColor* )color
14 | {
15 | CGRect rect = CGRectMake( 0, 0, 1, 1 );
16 |
17 | UIGraphicsBeginImageContextWithOptions( rect.size, NO, 0 );
18 | [ color setFill ];
19 | UIRectFill( rect );
20 | UIImage* image = UIGraphicsGetImageFromCurrentImageContext( );
21 | UIGraphicsEndImageContext( );
22 |
23 | return image;
24 | }
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/UIImage+Resize.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Resize.h
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage ( Resize )
12 |
13 | -( UIImage* ) scaleToSize: ( CGSize )size;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/UIImage+Resize.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Resize.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 20/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import "UIImage+Resize.h"
10 |
11 | @implementation UIImage ( Resize )
12 |
13 | -( UIImage* ) scaleToSize: ( CGSize )size
14 | {
15 | UIGraphicsBeginImageContext( size );
16 |
17 | CGContextRef context = UIGraphicsGetCurrentContext( );
18 | CGContextTranslateCTM( context, 0.0, size.height );
19 | CGContextScaleCTM( context, 1.0, -1.0 );
20 |
21 | CGContextDrawImage( context, CGRectMake( 0.0f, 0.0f, size.width, size.height ), self.CGImage );
22 |
23 | UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext( );
24 |
25 | UIGraphicsEndImageContext( );
26 |
27 | return scaledImage;
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/iosc.02-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/iosc.02-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_3_0
10 | #warning "This project uses features only available in iOS SDK 3.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iosc.02
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02Tests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02Tests/iosc.02Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ru.mrdekk.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CodeSamples/Lecture 7/iosc.02Tests/iosc_02Tests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iosc_02Tests.m
3 | // iosc.02Tests
4 | //
5 | // Created by MrDekk on 10/07/14.
6 | // Copyright (c) 2014 mrdekk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iosc_02Tests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iosc_02Tests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ios_course
2 | ==========
3 |
4 | iOS Dev Course
5 |
6 | Лицензия [Attribution-NonCommercial-ShareAlike 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode)
--------------------------------------------------------------------------------
/Snippets/lecture.3.m:
--------------------------------------------------------------------------------
1 | NSString* path = [ [ NSBundle mainBundle ] pathForResource: @"rss" ofType: @"xml" ];
2 |
3 | NSData* data = [ NSData dataWithContentsOfFile: path ];
4 |
5 | NSXMLParser* parser = [ [ [ NSXMLParser alloc ] initWithData: data ] autorelease ];
6 | parser.delegate = self;
7 | [ parser parse ];
8 |
9 | NSError* error = [ NSError errorWithDomain: @"my.domain" code: 12312 userInfo: [ NSDictionary dictionaryWithObjectsAndKeys: @"key1", @"A", @"key2", @"B", nil ] ];
10 |
11 | #pragma mark - NSXMLParsingDelegate
12 |
13 | -( void ) parser: ( NSXMLParser* )parser didStartElement: ( NSString* )elementName namespaceURI: ( NSString* )namespaceURI qualifiedName: ( NSString* )qName attributes: ( NSDictionary* )attributeDict
14 | {
15 | // do nothing
16 | }
17 |
18 | -( void ) parser: ( NSXMLParser* )parser didEndElement: ( NSString* )elementName namespaceURI: ( NSString* )namespaceURI qualifiedName: ( NSString* )qName
19 | {
20 | // do nothing
21 | }
22 |
23 | -( void ) parser: ( NSXMLParser* )parser foundCharacters: ( NSString* )string
24 | {
25 | // do nothing
26 | }
27 |
--------------------------------------------------------------------------------
/Snippets/lecture.4.m:
--------------------------------------------------------------------------------
1 | Грузим картинку
2 |
3 | _imageView.image = [ UIImage imageWithData: [ NSData dataWithContentsOfURL: [ NSURL URLWithString: @"http://itw66.ru/files/logo.png" ] ] ];
4 |
5 | Загружаем HTML в UIWebView
6 |
7 | [ _browser loadHTMLString: @"Hello, World " baseURL: [ NSURL URLWithString: @"http://yandex.ru" ] ];
8 |
9 | Функция прятания клавиатуры
10 |
11 | -( IBAction ) hideKeyboard: ( id )sender
12 | {
13 | if ( [ self becomeFirstResponder ] )
14 | [ self resignFirstResponder ];
15 | }
16 |
17 | Настраивать на "Did End On Exit"
18 |
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 1.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 2.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 3.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 4.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 5.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 6.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 6.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 7.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 7.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 8.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 8.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 8.university.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 8.university.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture 9.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture 9.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture PS. 1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture PS. 1.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture PS. 2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture PS. 2.pdf
--------------------------------------------------------------------------------
/lectures/iOS. Lecture PS. 3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrdekk/ios_course/448f714e8db45338141ad3a43089b2dafe4b0fd7/lectures/iOS. Lecture PS. 3.pdf
--------------------------------------------------------------------------------