Praktikum Entwicklung von Mediensystemen mit
Wintersemester 2013/2014 Christian Weiß, Dr. Alexander De Luca
Dienstag, 15. Oktober 13
Praktikum Entwicklung von Mediensystemen mit Wintersemester - - PowerPoint PPT Presentation
Praktikum Entwicklung von Mediensystemen mit Wintersemester 2013/2014 Christian Wei, Dr. Alexander De Luca Dienstag, 15. Oktober 13 Today Organization Introduction to iOS programming Hello World Assignment 1 iOS PEM - WS
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
2
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
3
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
4
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
5
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
6
Multi-touch, Web View, Map Kit, Camera, Image Picker...
Core Audio, PDF, Core Animation, Quartz 2D, OpenGL...
Core Location, Preferences, Address Book, Preferences...
File System, Kernel, Power Management, Security...
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
7
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
8
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
9
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
(https://developer.apple.com/technologies/tools/) 10
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
Build and run 11 Device and simulator selection Source editor Show/hide sidebars File navigator Utilities sidebar (API info)
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
12
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
Short introduction: https://developer.apple.com/library/mac/referencelibrary/GettingStarted/ Learning_Objective-C_A_Primer/index.html Detailed introduction: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ ProgrammingWithObjectiveC/Introduction/Introduction.html 13
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
14
MyClass.java Header.h Implementation.m Methods and method calls Methods and messages Attributes, setters, getters Properties, instance variables Constructor Initializer Interface Protocol Garbage Collection Automatic Reference Counting (ARC)
Different terminology, but for us very similar to writing Java code
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
andB: (NSString *) b;
andB: (NSString *) b { // do something with a and b } NSString* a = @"a"; NSString* b = @"b"; [self doSomethingWithA:a andB:b];
// do something }
[self doSomething]; 15
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
@property(strong, nonatomic) NSString *name;
NSString *labelText = self.name; labelText = [self name];
[self setName:@"Max"]; self.name = @"Max";
_name = @"Max";
16
nonatomic/atomic: use nonatomic to avoid multi-threading issues. strong/weak: refers to ownership. Always use strong except for properties that point to a parent. self.name: this syntax does NOT access the variable itself. It’s a getter/setter, just like the other syntax. _name: Use this instance variable in custom setters/getters and in init-methods only. In any other case, use the getter/setter.
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
_name = @"Max"; labelText = _name;
17
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
initWithParameter: parameter];
NSString *helloWorld = [NSString stringWithFormat:@"%@ World", hello];
NSMutableArray *mutableColors = [@[@"Green", @"Red", @"Yellow"] mutableCopy];
18
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
19
#import <Foundation/Foundation.h> @interface Student : NSObject @end #import "Student.h" @implementation Student @end
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
20
#import <Foundation/Foundation.h> @interface Student : NSObject @end #import "Student.h" @interface student() @end @implementation Student @end
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
21
#import <Foundation/Foundation.h> @interface Student : NSObject @property (strong, nonatomic) NSString *fullName; @property (nonatomic) NSUInteger number; @end #import "Student.h" @interface student() @end @implementation Student @end
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
22
#import <Foundation/Foundation.h> @interface Student : NSObject @property (strong, nonatomic) NSString *fullName; @property (nonatomic) NSUInteger number; @end #import "Student.h" @interface student() @end @implementation Student
{ NSLog(@"%@", fullName); _fullName = fullName; } @end
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
23
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
24
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
25
NSLog(@"switch changed"); if (sender.on) { self.myLabel.text = @"HelloWorld"; } else { self.myLabel.text = @""; } }
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
– viewDidLoad: – viewWillAppear: – viewDidAppear: – viewWillDisappear: – viewDidDisappear:
duration:(NSTimeInterval)duration;
UIViewController_Class/Reference/Reference.html 26
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
– applicationDidBecomeActive: – applicationDidEnterBackground: – applicationWillEnterForeground: – applicationWillTerminate:
UIApplicationDelegate_Protocol/Reference/Reference.html
27
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
28
Dienstag, 15. Oktober 13
iOS PEM - WS 2013/14
29
Dienstag, 15. Oktober 13