ITP 342 Mobile App Dev. Fundamentals

Similar documents
ITP 342 Mobile App Dev. Fundamentals

About MSDOSX. Lecture 0

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

ITP 342 Mobile App Dev. Code

Object-Oriented Programming with Objective-C. Lecture 2

Introduction to Programming Using Java (98-388)

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

Lexical Considerations


IPHONE. Development Jump Start. phil nash levelofindirection.com

Mobile Application Development

CSc Introduction to Computing

Objective-C. Stanford CS193p Fall 2013

Lexical Considerations

CS304 Object Oriented Programming Final Term

Computer Programming: C++

1 Lexical Considerations

Defining Classes and Methods

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

Lecture 2 Tao Wang 1

Introductory ios Development

BASIC ELEMENTS OF A COMPUTER PROGRAM

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.

9. Arrays. Compound Data Types: type name [elements]; int billy [5];

Computational Expression

CS113: Lecture 4. Topics: Functions. Function Activation Records

C++ Lecture 5 Arrays. CSci 588: Data Structures, Algorithms and Software Design.

Thursday, February 16, More C++ and root

Fundamental Concepts and Definitions

Object oriented programming C++

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

CS242 COMPUTER PROGRAMMING

ITP 342 Advanced Mobile App Dev. Memory

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

a data type is Types

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Introduction to Programming (Java) 4/12

UML IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

ios: Objective-C Primer

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004

Chapter 2 THE STRUCTURE OF C LANGUAGE


More loops Ch

Padasalai.Net s Model Question Paper

1B1b Classes in Java Part I

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

CS201 Some Important Definitions

Variables and Primitive Types

An Introduction to Processing

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

Introduction to Computer Science Midterm 3 Fall, Points

Exercise: Inventing Language

The high-level language has a series of primitive (builtin) types that we use to signify what s in the memory

Java+- Language Reference Manual

Chapter 4. Defining Classes I

Programming in C. main. Level 2. Level 2 Level 2. Level 3 Level 3

1/29/2018. Starting a Program Executes its main Function. ECE 220: Computer Systems & Programming. The Function main Divides into Two Parts

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

CS-201 Introduction to Programming with Java

aggregate data types member functions cis15 advanced programming techniques, using c++ lecture # II.1

Chapter 6 Introduction to Defining Classes

Chapter-8 DATA TYPES. Introduction. Variable:

Topic 10: Introduction to OO analysis and design

Tokens, Expressions and Control Structures

Methods. Contents Anatomy of a Method How to design a Method Static methods Additional Reading. Anatomy of a Method

Functions. Lab 4. Introduction: A function : is a collection of statements that are grouped together to perform an operation.

CS 231 Data Structures and Algorithms, Fall 2016

Fundamentals of Programming Session 25

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

CSC1322 Object-Oriented Programming Concepts

UNIT- 3 Introduction to C++

Object Oriented Programming with Java

IT 374 C# and Applications/ IT695 C# Data Structures

Object-Oriented Programming, Iouliia Skliarova

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Classes, Objects, and OOP in Java. June 16, 2017

7. C++ Class and Object

OBJECT ORIENTED PROGRAMMING

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING

public class Foo { private int var; public int Method1() { // var accessible anywhere here } public int MethodN() {

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. 1

Short Notes of CS201

Array. Prepared By - Rifat Shahriyar

Variables. Data Types.

Design Phase. Create a class Person. Determine the superclass. NSObject (in this case)

CISC-124. Dog.java looks like this. I have added some explanatory comments in the code, and more explanation after the code listing.

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

CS201 - Introduction to Programming Glossary By

Programming, numerics and optimization

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

CS193p Spring 2010 Thursday, April 29, 2010

Data Structures using OOP C++ Lecture 3

STRUCTURING OF PROGRAM

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

Object Oriented Design

CA4003 Compiler Construction Assignment Language Definition

Transcription:

ITP 342 Mobile App Dev Fundamentals

Object-oriented Programming Object-oriented programming (OOP) is a programming paradigm based on the concept of objects.

Classes A class can have attributes & actions (or members & s) Attributes (Members) Variables holding data Can be varying s Actions (Methods) Behaviors I love alliterations! Think of a as defining an action to be taken 3

Classes and Instances Think of a class as a cookie cutter Instances are the cookies Instance Class Instance 4

Example 5

Classes and Instances In Objective-C, classes and instances are both objects 6

Objective-C Classes Encapsulate data with the s that operate on that data An object is a runtime instance of a class Contains its own in-memory copy of the instance variables declared by that class & pointers to the s of the class Specification requires 2 distinct pieces: interface (.h) = public header implementation (.m) = private implementation 7

The Interface When you define a new class, you have to tell the compiler 3 things: Where the class came from Name its parent class Specify what of data is to be stored Describe the data that members of the class will contain These members are called the instance variables Define the of operations, or s, that can be used 8

Methods A class in Obj-C can declare 2 s of s Instance s A whose execution is scoped to a particular instance of the class Before you call an instance, you must first create an instance of the class Declaration is preceded by a minus (-) sign Class s Do not require you to create an instance Typically factory s for creating new instances of the class or accessing some piece of shared info Declaration is preceded by a plus (+) sign 9

No arguments Declaring Methods - (void) printinfo; return name takes no argument 10

Declaring Methods Return a primitive - (int) getage; return name takes no arguments 11

Declaring Methods Return an object - (NSString *) getname; return name takes no arguments 12

Declaring Methods One argument that is a primitive - (void) setage: (int) num; argument return name takes argument argument name 13

Declaring Methods One argument that is an object - (void) setname: (NSString *) name; argument return name takes argument argument name 14

Two arguments Declaring Methods - (void) setname: (NSString *) name age: (int) num; argument return name takes argument argument name 15

Method Example Method declaration syntax 16

Object Messaging To get an object to do something, you send it a message telling it to apply a Message expressions are enclosed in brackets The receiver is an object and the message tells it what to do Message is the name of a and any arguments The name serves to select a implementation Methods names in messages are often referred to as selectors [receiver message]; [person1 printinfo]; 17

Messaging Methods can also take parameters or arguments A message with a single argument affixes a colon (:) to the selector name & puts the argument right after the colon [person1 setage:21]; For multiple parameters, names should interleave the name with the arguments The s name naturally describes the arguments expected by the The sub-parts of the name - of the selector - are not optional, nor can their order be varied [person1 setname:@"trina" age:21]; 18

Messaging Example Example of calling an instance Call the insertobject by messaging the corresponding object [myarray insertobject:anobj atindex:0]; Example of calling a class arraywithcapacity: is a class on the NSMutableArray class that allocates and initializes a new instance of the class and returns it to your code NSMutableArray* myarray = nil; // Create a new array & assign it to the myarray variable myarray = [NSMutableArray arraywithcapacity:0]; 19

Methods Methods can return values BOOL vote; vote = [person1 canvote]; One message expression can be nested inside another [person1 setage:[person2 age]]; 20

Variables Variables allow us to store information The C programming language is a statically d language We have to tell upfront what kind of data a variable is going to hold Format to declare a variable: name; Examples: int num1; float score; Declare once, use many 21

Variables Specify the s of data to be stored in your class along with the names of those data s Data s can be: C basic s like int, float, char Objective-C defined s like BOOL Other classes that you have created or ones that are already created such as NSString Names Begin with a letter or underscore (_) Followed by any combo of letters (upper- or lowercase), underscores, or the digits 0-9 Cannot be a reserved word like int 22

Local Variables Variables Within a, declare using and name // In an implementation (.m) file, within a - (void) mymethod { // local variables BOOL canlegallyvote; int numofyears; NSString *name; } name = @"Tommy Trojan"; 23

Use CamelCase usecamelcase 24