SlideShare a Scribd company logo
Object-Oriented Programming Language
                                Chapter 2 : Programming in Objective-C


                                               Atit Patumvan
                               Faculty of Management and Information Sciences
                                             Naresuna University




วันอังคารที่ 7 กุมภาพันธ์ 12
2



                                                               Program 2.1 (ex02-01.m)



        // First program example

        #import <Foundation/Foundation.h>

        int main (int argc, const char * argv[])
        {
        ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        ! NSLog (@"Programming is fun");
        !
        ! [pool drain];
        ! return 0;
        }




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University      Object-Oriented Programming Language

วันอังคารที่ 7 กุมภาพันธ์ 12
3



                                                   Compile and Running Program


                    •          OSX
                               gcc -framework Foundation hello.m -o hello

                    •          Windows: GNUStep: gcc
                               gcc `gnustep-config --objc-flags` -L /GNUstep/System/
                               Library/Libraries hello.m -o hello -lgnustep-base -lobjc

                    •          Linux
                               gcc `gnustep-config --objc-flags` hello.m -o hello -I /
                               usr/include/GNUstep/ -L /usr/lib/GNUstep/ -lgnustep-
                               base



 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันอังคารที่ 7 กุมภาพันธ์ 12
4



                                                      Common Filename Extension



                     Extension                                                        Meaning
                                    .c                              C language source file
                          .cc, .cpp                                 C++ language source file
                                    .h                              Header file
                                   .m                               Objective-C source file
                                .mm                                 Objective-C++ source file
                                   .pl                              Perl source file
                                   .o                               Object (compiled) file

 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University             Object-Oriented Programming Language

วันอังคารที่ 7 กุมภาพันธ์ 12
5



                                             Explanation of Your First Program



        // First program example

        #import <Foundation/Foundation.h>

        int main (int argc, const char * argv[])
        {
        ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        ! NSLog (@"Programming is fun");
        !
        ! [pool drain];
        ! return 0;
        }




 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University   Object-Oriented Programming Language

วันอังคารที่ 7 กุมภาพันธ์ 12
6



                                                               Program 2.2 (ex02-02.m)


        #import <Foundation/Foundation.h>

        int main (int argc, const char * argv[])
        {
        ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        !
        ! NSLog (@"Programming is fun");
        ! NSLog (@"Programming in Objective-C is event more fun!");
        !
        ! [pool drain];
        ! return 0;
        }




         Programming is fun
         Programming in Objective-C is event more fun!

 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University      Object-Oriented Programming Language

วันอังคารที่ 7 กุมภาพันธ์ 12
7



                                                               Program 2.3 (ex02-03.m)



        #import <Foundation/Foundation.h>

        int main (int argc, const char * argv[])
        {
        ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        !
        ! NSLog (@"Testing...n..1n...2n....3");
        !
        ! [pool drain];
        ! return 0;
        }




        Testing...
        ..1
        ...2
        ....3
 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University      Object-Oriented Programming Language

วันอังคารที่ 7 กุมภาพันธ์ 12
8



                                                               Program 2.4 (ex02-04.m)

        #import <Foundation/Foundation.h>

        int main (int argc, const char * argv[])
        {
        ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        !
        ! int sum;
        !
        ! sum = 50 + 25;
        ! NSLog (@"The sum of 50 and 25 is %i", sum);
        !
        ! [pool drain];
        !
        ! return 0;
        }




        The sum of 50 and 25 is 75
 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University      Object-Oriented Programming Language

วันอังคารที่ 7 กุมภาพันธ์ 12
9



                                                               Program 2.5 (ex02-05.m)


        #import <Foundation/Foundation.h>

        int main (int argc, const char * argv[])
        {
        ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        !
        ! int value1, value2, sum;
        !
        ! value1 = 50;
        ! value2 = 25;
        ! sum = value1 + value2;
        ! NSLog (@"The sum of %i and %i is %i", value1, value2, sum);
        !
        ! [pool drain];
        !
        ! return 0;
        }

        The sum of 50 and 25 is 75
 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University      Object-Oriented Programming Language

วันอังคารที่ 7 กุมภาพันธ์ 12
Ad

Recommended

OOP Chapter 3: Classes, Objects and Methods
OOP Chapter 3: Classes, Objects and Methods
Atit Patumvan
 
OOP Chapter 7 : More on Classes
OOP Chapter 7 : More on Classes
Atit Patumvan
 
OOP Chapter 4: Data Type and Expressions
OOP Chapter 4: Data Type and Expressions
Atit Patumvan
 
Chapter 9 : Polymorphism, Dynamic Typing, and Dynamic Binding
Chapter 9 : Polymorphism, Dynamic Typing, and Dynamic Binding
Atit Patumvan
 
Detecting aspect-specific code smells using Ekeko for AspectJ
Detecting aspect-specific code smells using Ekeko for AspectJ
Coen De Roover
 
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012
Coen De Roover
 
A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X Transformation
Coen De Roover
 
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
Coen De Roover
 
Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...
Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...
journalBEEI
 
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Institute of Science Tokyo
 
Unit 8
Unit 8
rohassanie
 
SDE - Dynamic Analysis
SDE - Dynamic Analysis
Jorge Ressia
 
Life & Work of Robin Milner | Turing100@Persistent
Life & Work of Robin Milner | Turing100@Persistent
Persistent Systems Ltd.
 
Data structure week 1
Data structure week 1
karmuhtam
 
Chapter 02 functions -class xii
Chapter 02 functions -class xii
Praveen M Jigajinni
 
OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping
Atit Patumvan
 
Introduction to objective c
Introduction to objective c
Mayank Jalotra
 
Objective-C A Beginner's Dive (with notes)
Objective-C A Beginner's Dive (with notes)
Altece
 
Objc
Objc
Pragati Singh
 
Fp201 unit1 1
Fp201 unit1 1
rohassanie
 
iOS Hackathon 2012 Objective-C talk
iOS Hackathon 2012 Objective-C talk
Gabriel Lim
 
Obj c
Obj c
ไก่ป๊อบ ออนไลน์
 
Objective-C
Objective-C
Abdlhadi Oul
 
Objective-C A Beginner's Dive
Objective-C A Beginner's Dive
Altece
 
Presentation 1st
Presentation 1st
Connex
 
SPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and Flowchart
Mohammad Imam Hossain
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
Petr Dvorak
 
Cappuccino
Cappuccino
Jelle Vandebeeck
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOS
Petr Dvorak
 
An intro to programming
An intro to programming
WolfFlight
 

More Related Content

What's hot (7)

Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...
Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...
journalBEEI
 
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Institute of Science Tokyo
 
Unit 8
Unit 8
rohassanie
 
SDE - Dynamic Analysis
SDE - Dynamic Analysis
Jorge Ressia
 
Life & Work of Robin Milner | Turing100@Persistent
Life & Work of Robin Milner | Turing100@Persistent
Persistent Systems Ltd.
 
Data structure week 1
Data structure week 1
karmuhtam
 
Chapter 02 functions -class xii
Chapter 02 functions -class xii
Praveen M Jigajinni
 
Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...
Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...
journalBEEI
 
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Institute of Science Tokyo
 
SDE - Dynamic Analysis
SDE - Dynamic Analysis
Jorge Ressia
 
Life & Work of Robin Milner | Turing100@Persistent
Life & Work of Robin Milner | Turing100@Persistent
Persistent Systems Ltd.
 
Data structure week 1
Data structure week 1
karmuhtam
 

Similar to OOP: Chapter 2: Programming in Objective-C (20)

OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping
Atit Patumvan
 
Introduction to objective c
Introduction to objective c
Mayank Jalotra
 
Objective-C A Beginner's Dive (with notes)
Objective-C A Beginner's Dive (with notes)
Altece
 
Objc
Objc
Pragati Singh
 
Fp201 unit1 1
Fp201 unit1 1
rohassanie
 
iOS Hackathon 2012 Objective-C talk
iOS Hackathon 2012 Objective-C talk
Gabriel Lim
 
Obj c
Obj c
ไก่ป๊อบ ออนไลน์
 
Objective-C
Objective-C
Abdlhadi Oul
 
Objective-C A Beginner's Dive
Objective-C A Beginner's Dive
Altece
 
Presentation 1st
Presentation 1st
Connex
 
SPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and Flowchart
Mohammad Imam Hossain
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
Petr Dvorak
 
Cappuccino
Cappuccino
Jelle Vandebeeck
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOS
Petr Dvorak
 
An intro to programming
An intro to programming
WolfFlight
 
Lecture 03
Lecture 03
Nguyen Thanh Xuan
 
Keil tutorial
Keil tutorial
anishgoel
 
Java 2 chapter 10 - basic oop in java
Java 2 chapter 10 - basic oop in java
let's go to study
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Yandex
 
SysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming Language
Wongyos Keardsri
 
OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping
Atit Patumvan
 
Introduction to objective c
Introduction to objective c
Mayank Jalotra
 
Objective-C A Beginner's Dive (with notes)
Objective-C A Beginner's Dive (with notes)
Altece
 
iOS Hackathon 2012 Objective-C talk
iOS Hackathon 2012 Objective-C talk
Gabriel Lim
 
Objective-C A Beginner's Dive
Objective-C A Beginner's Dive
Altece
 
Presentation 1st
Presentation 1st
Connex
 
SPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and Flowchart
Mohammad Imam Hossain
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
Petr Dvorak
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOS
Petr Dvorak
 
An intro to programming
An intro to programming
WolfFlight
 
Keil tutorial
Keil tutorial
anishgoel
 
Java 2 chapter 10 - basic oop in java
Java 2 chapter 10 - basic oop in java
let's go to study
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Yandex
 
SysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming Language
Wongyos Keardsri
 
Ad

More from Atit Patumvan (20)

Iot for smart agriculture
Iot for smart agriculture
Atit Patumvan
 
An Overview of eZee Burrp! (Philus Limited)
An Overview of eZee Burrp! (Philus Limited)
Atit Patumvan
 
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
Atit Patumvan
 
Chapter 1 mathmatics tools
Chapter 1 mathmatics tools
Atit Patumvan
 
Chapter 1 mathmatics tools
Chapter 1 mathmatics tools
Atit Patumvan
 
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556
Atit Patumvan
 
Chapter 0 introduction to theory of computation
Chapter 0 introduction to theory of computation
Atit Patumvan
 
Media literacy
Media literacy
Atit Patumvan
 
Chapter 01 mathmatics tools (slide)
Chapter 01 mathmatics tools (slide)
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 8
การบริหารเชิงคุณภาพ ชุดที่ 8
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 7
การบริหารเชิงคุณภาพ ชุดที่ 7
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 6
การบริหารเชิงคุณภาพ ชุดที่ 6
Atit Patumvan
 
Computer Programming Chapter 5 : Methods
Computer Programming Chapter 5 : Methods
Atit Patumvan
 
Computer Programming Chapter 4 : Loops
Computer Programming Chapter 4 : Loops
Atit Patumvan
 
Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 5
การบริหารเชิงคุณภาพ ชุดที่ 5
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 4
การบริหารเชิงคุณภาพ ชุดที่ 4
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 3
การบริหารเชิงคุณภาพ ชุดที่ 3
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 2
การบริหารเชิงคุณภาพ ชุดที่ 2
Atit Patumvan
 
Computer Programming: Chapter 1
Computer Programming: Chapter 1
Atit Patumvan
 
Iot for smart agriculture
Iot for smart agriculture
Atit Patumvan
 
An Overview of eZee Burrp! (Philus Limited)
An Overview of eZee Burrp! (Philus Limited)
Atit Patumvan
 
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
Atit Patumvan
 
Chapter 1 mathmatics tools
Chapter 1 mathmatics tools
Atit Patumvan
 
Chapter 1 mathmatics tools
Chapter 1 mathmatics tools
Atit Patumvan
 
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556
รายงานการประเมินคุณภาพภายใน ปีงบประมาณ 2556
Atit Patumvan
 
Chapter 0 introduction to theory of computation
Chapter 0 introduction to theory of computation
Atit Patumvan
 
Chapter 01 mathmatics tools (slide)
Chapter 01 mathmatics tools (slide)
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 8
การบริหารเชิงคุณภาพ ชุดที่ 8
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 7
การบริหารเชิงคุณภาพ ชุดที่ 7
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 6
การบริหารเชิงคุณภาพ ชุดที่ 6
Atit Patumvan
 
Computer Programming Chapter 5 : Methods
Computer Programming Chapter 5 : Methods
Atit Patumvan
 
Computer Programming Chapter 4 : Loops
Computer Programming Chapter 4 : Loops
Atit Patumvan
 
Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 5
การบริหารเชิงคุณภาพ ชุดที่ 5
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 4
การบริหารเชิงคุณภาพ ชุดที่ 4
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 3
การบริหารเชิงคุณภาพ ชุดที่ 3
Atit Patumvan
 
การบริหารเชิงคุณภาพ ชุดที่ 2
การบริหารเชิงคุณภาพ ชุดที่ 2
Atit Patumvan
 
Computer Programming: Chapter 1
Computer Programming: Chapter 1
Atit Patumvan
 
Ad

Recently uploaded (20)

IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
English 3 Quarter 1_LEwithLAS_Week 1.pdf
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
 
List View Components in Odoo 18 - Odoo Slides
List View Components in Odoo 18 - Odoo Slides
Celine George
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
June 2025 Progress Update With Board Call_In process.pptx
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
 
English 3 Quarter 1_LEwithLAS_Week 1.pdf
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
 
List View Components in Odoo 18 - Odoo Slides
List View Components in Odoo 18 - Odoo Slides
Celine George
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 

OOP: Chapter 2: Programming in Objective-C

  • 1. Object-Oriented Programming Language Chapter 2 : Programming in Objective-C Atit Patumvan Faculty of Management and Information Sciences Naresuna University วันอังคารที่ 7 กุมภาพันธ์ 12
  • 2. 2 Program 2.1 (ex02-01.m) // First program example #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; ! NSLog (@"Programming is fun"); ! ! [pool drain]; ! return 0; } Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันอังคารที่ 7 กุมภาพันธ์ 12
  • 3. 3 Compile and Running Program • OSX gcc -framework Foundation hello.m -o hello • Windows: GNUStep: gcc gcc `gnustep-config --objc-flags` -L /GNUstep/System/ Library/Libraries hello.m -o hello -lgnustep-base -lobjc • Linux gcc `gnustep-config --objc-flags` hello.m -o hello -I / usr/include/GNUstep/ -L /usr/lib/GNUstep/ -lgnustep- base Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันอังคารที่ 7 กุมภาพันธ์ 12
  • 4. 4 Common Filename Extension Extension Meaning .c C language source file .cc, .cpp C++ language source file .h Header file .m Objective-C source file .mm Objective-C++ source file .pl Perl source file .o Object (compiled) file Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันอังคารที่ 7 กุมภาพันธ์ 12
  • 5. 5 Explanation of Your First Program // First program example #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; ! NSLog (@"Programming is fun"); ! ! [pool drain]; ! return 0; } Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันอังคารที่ 7 กุมภาพันธ์ 12
  • 6. 6 Program 2.2 (ex02-02.m) #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; ! ! NSLog (@"Programming is fun"); ! NSLog (@"Programming in Objective-C is event more fun!"); ! ! [pool drain]; ! return 0; } Programming is fun Programming in Objective-C is event more fun! Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันอังคารที่ 7 กุมภาพันธ์ 12
  • 7. 7 Program 2.3 (ex02-03.m) #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; ! ! NSLog (@"Testing...n..1n...2n....3"); ! ! [pool drain]; ! return 0; } Testing... ..1 ...2 ....3 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันอังคารที่ 7 กุมภาพันธ์ 12
  • 8. 8 Program 2.4 (ex02-04.m) #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; ! ! int sum; ! ! sum = 50 + 25; ! NSLog (@"The sum of 50 and 25 is %i", sum); ! ! [pool drain]; ! ! return 0; } The sum of 50 and 25 is 75 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันอังคารที่ 7 กุมภาพันธ์ 12
  • 9. 9 Program 2.5 (ex02-05.m) #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { ! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; ! ! int value1, value2, sum; ! ! value1 = 50; ! value2 = 25; ! sum = value1 + value2; ! NSLog (@"The sum of %i and %i is %i", value1, value2, sum); ! ! [pool drain]; ! ! return 0; } The sum of 50 and 25 is 75 Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language วันอังคารที่ 7 กุมภาพันธ์ 12