SlideShare une entreprise Scribd logo
1  sur  9
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

Contenu connexe

Tendances

Tendances (7)

Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...
Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...
Python Application: Visual Approach of Hopfield Discrete Method for Hiragana ...
 
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
 
Unit 8
Unit 8Unit 8
Unit 8
 
SDE - Dynamic Analysis
SDE - Dynamic AnalysisSDE - Dynamic Analysis
SDE - Dynamic Analysis
 
Life & Work of Robin Milner | Turing100@Persistent
Life & Work of Robin Milner | Turing100@PersistentLife & Work of Robin Milner | Turing100@Persistent
Life & Work of Robin Milner | Turing100@Persistent
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 

Similaire à OOP: Chapter 2: Programming in Objective-C

OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping
Atit Patumvan
 
Requirment
RequirmentRequirment
Requirment
stat
 
[計一] Basic r programming final0918
[計一] Basic r programming   final0918[計一] Basic r programming   final0918
[計一] Basic r programming final0918
Yen_CY
 

Similaire à OOP: Chapter 2: Programming in Objective-C (20)

OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping OOP Chapter 5 : Program Looping
OOP Chapter 5 : Program Looping
 
MAVRL Workshop 2014 - Python Materials Genomics (pymatgen)
MAVRL Workshop 2014 - Python Materials Genomics (pymatgen)MAVRL Workshop 2014 - Python Materials Genomics (pymatgen)
MAVRL Workshop 2014 - Python Materials Genomics (pymatgen)
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
 
HiPEAC 2019 Tutorial - Maestro RTOS
HiPEAC 2019 Tutorial - Maestro RTOSHiPEAC 2019 Tutorial - Maestro RTOS
HiPEAC 2019 Tutorial - Maestro RTOS
 
cv
cvcv
cv
 
Massively Parallel Process with Prodedural Python by Ian Huston
Massively Parallel Process with Prodedural Python by Ian HustonMassively Parallel Process with Prodedural Python by Ian Huston
Massively Parallel Process with Prodedural Python by Ian Huston
 
biopython, doctest and makefiles
biopython, doctest and makefilesbiopython, doctest and makefiles
biopython, doctest and makefiles
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind Plone
 
Compiling Qt Apps
Compiling Qt AppsCompiling Qt Apps
Compiling Qt Apps
 
PHYTON-REPORT.pdf
PHYTON-REPORT.pdfPHYTON-REPORT.pdf
PHYTON-REPORT.pdf
 
EuroHPC AI in DAPHNE
EuroHPC AI in DAPHNEEuroHPC AI in DAPHNE
EuroHPC AI in DAPHNE
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
Requirment
RequirmentRequirment
Requirment
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
Pythonpresent
PythonpresentPythonpresent
Pythonpresent
 
Presentation on python
Presentation on pythonPresentation on python
Presentation on python
 
Resume
ResumeResume
Resume
 
[計一] Basic r programming final0918
[計一] Basic r programming   final0918[計一] Basic r programming   final0918
[計一] Basic r programming final0918
 

Plus de Atit Patumvan

แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ตแบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ต
Atit Patumvan
 
Chapter 1 mathmatics tools
Chapter 1 mathmatics toolsChapter 1 mathmatics tools
Chapter 1 mathmatics tools
Atit Patumvan
 
Computer Programming Chapter 5 : Methods
Computer Programming Chapter 5 : MethodsComputer Programming Chapter 5 : Methods
Computer Programming Chapter 5 : Methods
Atit Patumvan
 
Computer Programming Chapter 4 : Loops
Computer Programming Chapter 4 : Loops Computer Programming Chapter 4 : Loops
Computer Programming Chapter 4 : Loops
Atit Patumvan
 
Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)
Atit Patumvan
 

Plus de Atit Patumvan (20)

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

Dernier

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Dernier (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 

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