einführung in cocoa re-usable content in 3d und simulationssystemen prof. dr. manfred thaller, ss...

41
Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson Marambio

Upload: bathilda-schlichte

Post on 05-Apr-2015

108 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Einführung in Cocoa

Re-usable Content in 3D und SimulationssystemenProf. Dr. Manfred Thaller, SS 2012

Do, 14-15.30 Uhr, Archäologie-PoolReferent: Nelson Marambio

Page 2: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Framework vs. Klassenbibliothek

• Klassenbibliothek (z.B. Java): ausformulierte Attribute

Einführung in Cocoa 2

Page 3: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Framework vs. Klassenbibliothek

• Klassenbibliothek (z.B. Java): ausformulierte Attribute

Werkzeuge zu verschiedenen Bereichen, keine Spezialisierung

Einführung in Cocoa 3

Page 4: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Framework vs. Klassenbibliothek

• Klassenbibliothek (z.B. Java): ausformulierte Attribute

Werkzeuge zu verschiedenen Bereichen, keine Spezialisierung

• Framework: Bibliothek + Grundgerüst für grafische Anwendung

Einführung in Cocoa 4

Page 5: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Framework vs. Klassenbibliothek

• Klassenbibliothek (z.B. Java): ausformulierte Attribute

Werkzeuge zu verschiedenen Bereichen, keine Spezialisierung

• Framework: Bibliothek + Grundgerüst für grafische Anwendung (Dummy)

Auswahl je nach Kontext, dabei implizite Bedarfsformulierung notwendig

Einführung in Cocoa 5

Page 6: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Framework

• Dummy: enthält „tote“ GUI

Einführung in Cocoa 6

Page 7: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Framework

• Dummy: enthält „tote“ GUI• Klassenbibliothek konkret implementiert

Einführung in Cocoa 7

Page 8: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Framework

• Dummy: enthält „tote“ GUI• Klassenbibliothek konkret implementiert• Benutzer programmiert nicht völlig neu,

sondern überschreibt gesetzte Standardwerte /-routinen

Einführung in Cocoa 8

Page 9: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Framework

• Dummy: enthält „tote“ GUI• Klassenbibliothek konkret implementiert• Benutzer programmiert nicht völlig neu,

sondern überschreibt gesetzte Standardwerte /-routinen

• Framework setzt Benutzer [sinnvolle] Grenzen

Einführung in Cocoa 9

Page 10: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Framework

• Dummy: enthält „tote“ GUI• Klassenbibliothek konkret implementiert• Benutzer programmiert nicht völlig neu,

sondern überschreibt gesetzte Standardwerte /-routinen

• Framework setzt Benutzer [sinnvolle] Grenzen Was das Framework nicht vorsieht, kann der

Benutzer nicht implementieren

Einführung in Cocoa 10

Page 11: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Cocoa: Historie

• Basiert auf Betriebsystem NeXTStep (Produkt der Firma NeXT, Gründer: Steve Jobs)

Einführung in Cocoa 11

Page 12: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Cocoa: Historie

• Basiert auf Betriebsystem NeXTStep (Produkt der Firma NeXT, Gründer: Steve Jobs)

• Später: NeXTStep Grundlage für MacOS X

Einführung in Cocoa 12

Page 13: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Cocoa: Historie

• Basiert auf Betriebsystem NeXTStep (Produkt der Firma NeXT, Gründer: Steve Jobs)

• Später: NeXTStep Grundlage für MacOS X• [daher Präfix NS bei Datentypen / Klassen]

Einführung in Cocoa 13

Page 14: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Cocoa: Historie

• Basiert auf Betriebsystem NeXTStep (Produkt der Firma NeXT, Gründer: Steve Jobs)

• Später: NeXTStep Grundlage für MacOS X• [daher Präfix NS bei Datentypen / Klassen]• Konsequente Objektorientierung

Einführung in Cocoa 14

Page 15: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Cocoa: Allgemein

• MVC

Einführung in Cocoa 15

Page 16: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Cocoa: Allgemein

• MVC = Modell-View-Controller

Einführung in Cocoa 16

Page 17: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Cocoa: Allgemein

• MVC = Modell-View-Controller• Modell: konkrete Nutzdaten innerhalb der

Anwendung

Einführung in Cocoa 17

Page 18: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Cocoa: Allgemein

• MVC = Modell-View-Controller• Modell: konkrete Nutzdaten innerhalb der

Anwendung• View: grafische Elemente zur Visualisierung

des Modell

Einführung in Cocoa 18

Page 19: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Cocoa: Allgemein

• MVC = Modell-View-Controller• Modell: konkrete Nutzdaten innerhalb der

Anwendung• View: grafische Elemente zur Visualisierung

des Modell• Controller: ermöglicht Kommunikation zw.

Modell und View eigentliche Anwendungs-Logik

Einführung in Cocoa 19

Page 20: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Architektur

• Zentrales Objekt NSApplication

Einführung in Cocoa 20

Page 21: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Architektur

• Zentrales Objekt NSApplication Mutterschiff ?

Einführung in Cocoa 21

Page 22: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Architektur

• Zentrales Objekt NSApplication Mutterschiff ? Telefonvermittlung !

Einführung in Cocoa 22

Page 23: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Architektur

• Zentrales Objekt NSApplication Mutterschiff ? Telefonvermittlung !

• leitet Nachrichten / Ereignisse an zuständige Klassen weiter

Einführung in Cocoa 23

Page 24: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Architektur

• Zentrales Objekt NSApplication Mutterschiff ? Telefonvermittlung !

• leitet Nachrichten / Ereignisse an zuständige Klassen weiter

• Prinzip: Delegates, Klassen stehen parallel zu NSApplication, keine Ableitung

Einführung in Cocoa 24

Page 25: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Protokolle

• Protokoll: Menge von Methoden, die der Interaktion von Objektion dienen

Einführung in Cocoa 25

Page 26: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Protokolle

• Protokoll: Menge von Methoden, die der Interaktion von Objektion dienen

• Formelles Protokoll: Klasse muss Methode x implementieren (obligatorisch)

Einführung in Cocoa 26

Page 27: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Protokolle

• Protokoll: Menge von Methoden, die der Interaktion von Objektion dienen

• Formelles Protokoll: Klasse muss Methode x implementieren (obligatorisch)

• Informelles Protokoll: Klasse kann Methode x implementieren (optional), häufiger benutzt

Einführung in Cocoa 27

Page 28: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Protokolle II

• Informelles Protokoll wird über eine Kategorie umgesetzt

Einführung in Cocoa 28

Page 29: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Protokolle II

• Informelles Protokoll wird über eine Kategorie umgesetzt

• Vorhandene Klasse wird nicht abgeleitet, sondern erweitert (vgl. Delegates)

Einführung in Cocoa 29

Page 30: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Observer

• Observer: schwächere Form der Delegates

Einführung in Cocoa 30

Page 31: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Observer

• Observer: schwächere Form der Delegates• Eher informativer Charakter

Einführung in Cocoa 31

Page 32: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Observer

• Observer: schwächere Form der Delegates• Eher informativer Charakter• Objekt_1 „bespitzelt“ andere Objekt_2

Einführung in Cocoa 32

Page 33: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Observer

• Observer: schwächere Form der Delegates• Eher informativer Charakter• Objekt_1 „bespitzelt“ andere Objekt_2

Objekt_2 weiß nichts von Beobachtung

Einführung in Cocoa 33

Page 34: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Observer

• Observer: schwächere Form der Delegates• Eher informativer Charakter• Objekt_1 „bespitzelt“ andere Objekt_2

Objekt_2 weiß nichts von Beobachtung• Objekt_1 muss sich beim NotificationCenter

für die Beobachtung von Objekt_2 registrieren

Einführung in Cocoa 34

Page 35: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Observer

• Observer: schwächere Form der Delegates• Eher informativer Charakter• Objekt_1 „bespitzelt“ andere Objekt_2

Objekt_2 weiß nichts von Beobachtung• Objekt_1 muss sich beim NotificationCenter

für die Beobachtung von Objekt_2 registrieren

Einführung in Cocoa 35

Page 36: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Target-Action

• Verbindung von [mitteilender] Methode eines Objekts an einen reagierenden Controller

Einführung in Cocoa 36

Page 37: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Target-Action

• Verbindung von [mitteilender] Methode eines Objekts an einen reagierenden Controller

• Einziges Argument: Referenz auf Sender der Nachricht

Einführung in Cocoa 37

Page 38: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Target-Action

• Verbindung von [mitteilender] Methode eines Objekts an einen reagierenden Controller

• Einziges Argument: Referenz auf Sender der Nachricht

Einführung in Cocoa 38

Page 39: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Programmieren

????

Einführung in Cocoa 39

Page 40: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Programmieren

!!! Objective-C !!!

Einführung in Cocoa 40

Page 41: Einführung in Cocoa Re-usable Content in 3D und Simulationssystemen Prof. Dr. Manfred Thaller, SS 2012 Do, 14-15.30 Uhr, Archäologie-Pool Referent: Nelson

Literatur

• K. Surendorf, M. Hardt: Einstieg in Objective-C 2.0 und COCOA

• Artikel „Framework“, http://en.wikipedia.org/wiki/Software_framework

Einführung in Cocoa 41