Objective-C 기초 2 DongJoo Kim. Instagram Initial Release - 2010.10.6 Users - 10 Million ( in 355days) Funding - 약 80 억원 기업가치 - 350 억원 ( 추정 )

Slides:



Advertisements
Similar presentations
November 7, 2009 Blocks - Its Whats for Dinner Desert Code Camp 6.
Advertisements

Objective-C Lecture 2 Memory management Memory management in OC is semi- automatic: The programmer must allocate memory for objects either a) explicitly.
1 Objective-C and Object-Oriented Programming. 2 Introduction Objective-C is implemented as set of extensions to the C language. It's designed to give.
Black Jack in Objective-C
suppose you had Bumblebee, Jet, and Bird classes. All three, although unrelated, implement the flying behavior, and so you could say they are each a Flyer.
Carnegie Mellon 1 Dynamic Memory Allocation: Basic Concepts : Introduction to Computer Systems 17 th Lecture, Oct. 21, 2010 Instructors: Randy Bryant.
Chris Riesbeck, Fall 2007 Dynamic Memory Allocation Today Dynamic memory allocation – mechanisms & policies Memory bugs.
EC-241 Object-Oriented Programming
IOS and AddressBook CS4521. Address Book UI Framework Exploring Contacts.
CS 3800 Su 11 Beg. IOS Dev L4 Obj C part 1 CS 3800 Introduction to IOS programming Summer 2011 G. Zimmerman.
Anatomy of an iPhone Application Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
IPhone Development Crash Course By Dylan Harris
IPhone/iPad Programming Reuben Edwards. Contents iPhone & iPad Layout Objective-C UIKit Other APIs Alternative Tools.
ITouch/iPhone SDK A study using Cognitive Dimensions.
IPhone Development JaxCodeCamp Who am I David Fekke.NET Developer, ColdFusion Work at LPS Presenter JaxDug, JaxJug, JSUG & JaxFusion Mac User 1986.
IPhone 101. Outline Objective-C Random bits of the API Using the simulator Debugging with Xcode.
BY MUKTADIUR RAHMAN DATE: JUNE 10, 2010 Introduction to iPhone SDK.
Intro to Objective-C Syntax: What’s most confusing about Objective-C? Most class names start with NS: NSString, NSObject Parameter lists are not comma.
Objective-C Quinton Palet. Introduction  Objective-C was developed to bring large scale software development the power of the object-oriented approach.
Objective-C for C# and Java Developers JaxCodeCamp 2012.
Memory Management and Automatic Reference Counting/ Copying Objects Archiving Copyright © 2012 by Yong-Gu Lee
IOS WorkShoP Xcode 4 iOS 5 : “A Primer”. Objective-C iOS applications are written in Objective-C language using the Cocoa Touch library Objective-C is.
Refactoring Moving a console app to a UI app. Refactoring Goal: change a console app to a UI app Principles: The main.m goes away The local variables.
More on Classes Inheritance Copyright © 2012 by Yong-Gu Lee
Object Oriented Programming
Introduction to Objective-C and Xcode (Part 3) FA 175 Intro to Mobile App Development.
Toward iOS programming. Overview  Objective-C is an object oriented language.  follows ANSI C style coding with methods from Smalltalk  Flexible almost.
OS X Development Tom Schroeder. Table of Contents Who cares? HistoryObjective-CCocoaEnvironmentDesign.
Objective-C First Part adapted from a presentation by Kevin Layer.
Objective-C OOP Spring OOP Conceptually the same as C++, Java, and all other object oriented languages The syntax, however… …is, well, different.
1 Introduction to Objective-C Programming (Level: Beginner) Lecture 1.
Introduction to Building Windows 8.1 & Windows Phone Applications.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Objective C. Основан на C Объектно-ориентированный Использует сообщения Динамический Протоколы Интроспекция.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Objective-C Memory management Memory management is semi-automatic: The programmer must allocate memory for objects either a) explicitly (alloc) or b) indirectly.
Last Lecture objective C memory management rules Wrote our first iPhone app a quiz app xib and nib files and interface editor MVC pattern IBOutlet IBAction.
Introduction to Objective-C and Xcode (Part 5) FA 175 Intro to Mobile App Development.
Course Summary Xcode & iPhone Simulator
OOP with Objective-C Categories, Protocols and Declared Properties.
The Controller in MVC of iOS CS4521. The controller in the MVC  Controller  Knows about model and view objects  The brains of the operation  Manages.
Persistence CS 344 Mobile App Development Robert Muller.
Simple Scene Management a layer has the size of the device screen it defines appearance and behavior a scene is composed of one or more layers app transitions.
More Objective-C Details FA 172 Intro to Mobile App Development.
Introduction to Objective-C Spring Goals An introduction to Objective-C As implemented by the Apple LLVM Compiler 4.0 (a.k.a. Clang) Only the basics…
The iOS Platform and SDK. iOS iPhoneiPad Mini iPad.
Lec 5 Obj-C part 2 CS 3800 Introduction to IOS programming Lecture 5 Summer 2011.
OBJECTIVE C Kurt Ladendorf. General Knowledge  Super set of C  Smalltalk  Mainly used for iOS and other Apple development.
IOS Programming Medialogy, Semester 7, 2010 Aalborg University, Aalborg David Meredith
2/20/2016 EEC492/693/793 - iPhone Application Development 12/20/2016 EEC492/693/793 - iPhone Application Development 1 EEC-492/693/793 iPhone Application.
Learning & Development Mobile apps for iPhone & iPad.
Introduction to Objective-C and Xcode (Part 4) FA 175 Intro to Mobile App Development.
MORE on classes in …... OOP terminology in Objective-C Class: defines the grouping of data and code type of entity Object or Instance: a specific instantiation.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Objective-C: Intro Michelle Alexander COMS E6998 2/4/2013.
이미지 뷰의 애니메이션 이미지 뷰는 자체적으로 애니메이션 기능을 제공하고 있습니다.
Lec 12 Pickers CS 3800 Introduction to IOS programming Lecture 12 Summer 2011.
Course Summary Xcode & iPhone Simulator
Minimising memory churn
Module 9: Memory and Resource Management
EEC-492/693/793 iPhone Application Development
Lecture 9 Concepts of Programming Languages
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Abstract Data Types and Encapsulation Concepts
EEC-492/693/793 iPhone Application Development
Lecture 9 Concepts of Programming Languages
Presentation transcript:

Objective-C 기초 2 DongJoo Kim

Instagram Initial Release Users - 10 Million ( in 355days) Funding - 약 80 억원 기업가치 억원 ( 추정 )

Agenda Object Typing Reference Counting - retain / release - autorelease

Cocoa Touch Provides a very rich starting point for exploring app design Main Frameworks - Foundation Kit - UIKit - MapKit

MVC Model Controller Model View Controller - UI Logic View – UI Component 배치 Model - Data

Object Vehicle - Ship : Vehicle - Ship *s = [[Ship alloc] init]; [s shoot]; [s move]; // 다음 코드에 문제가 있을까요 ?

Object Vehicle - Ship : Vehicle - Ship *s = [[Ship alloc] init]; [s shoot]; [s move]; Vehicle *v = s; // 다음 코드에 문제가 있을까요 ?

Object Vehicle - Ship : Vehicle - Ship *s = [[Ship alloc] init]; [s shoot]; [s move]; Vehicle *v = s; [v shoot]; // 다음 코드에 문제가 있을까요 ?

Object Typing 3 Vehicle *v = s; [v shoot]; // 다음 코드에 문제가 있을까요 ?

Foo - (void) - (int ) - 특정메소드를 구현하라 / 강제, 권유 하는것 구현안하면 컴파일 워닝이 발생

UITableViewDelegate – tableView:heightForRowAtIndexPath: – tableView:didSelectRowAtIndexPath:

Reference Counting Why Reference Counting - No Garbage Collection Object 를 이용할때 Reference Count 증가 Object 를 더 이상 이용하지 않을때 Reference count 감소 Reference Count 가 0 가 될때 해당 object 는 메모리에서 제거됨

Reference Counting Why Reference Counting - No Garbage Collection - 사실 있음 !!!! autorelease Object 를 이용할때 Reference Count 증가 Object 를 더 이상 이용하지 않을때 Reference count 감소 Reference Count 가 0 가 될때 해당 object 는 메모리에서 제거됨

Reference Count 증가 예외 ) new, alloc, copy 혹은 factory 함수등을 통해 Object 를 가지고 올때 -> Reference Count 증가할 필요 X 그외에는 Object 에게 retain 메세지를 전송한다. ( 아마 = 을 사용해서 object 를 갖고 올때 )

예제와 함께 보기 NSNumber *myInt =[NSNumber numberWithInteger:100]; NSNumber *myInt2 ; NSMutableArray *myArr = [NSMutableArray arrayWithCapacity:5]; is %lx”,(unsigned long)[myInt retainCount]); [myArr addObject:myInt]; is %lx”,(unsigned long)[myInt retainCount]); myInt2 = myInt; is %lx”,(unsigned long)[myInt2 retainCount]); [myInt retain]; is %lx”,(unsigned long)[myInt retainCount]); is %lx”,(unsigned long)[myInt2 retainCount]);

예제와 함께 보기 - 정답 NSNumber *myInt =[NSNumber numberWithInteger:100]; NSNumber *myInt2 ; NSMutableArray *myArr = [NSMutableArray arrayWithCapacity:5]; is %lx”,(unsigned long)[myInt retainCount]); [myArr addObject:myInt]; is %lx”,(unsigned long)[myInt retainCount]); myInt2 = myInt; is %lx”,(unsigned long)[myInt2 retainCount]); [myInt retain]; is %lx”,(unsigned long)[myInt retainCount]); is %lx”,(unsigned long)[myInt2 retainCount]);

AutoRelease - 데스노트 지금은 안죽지만 언젠가 죽음. (pool 이 release 될때 ) NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString* testString = [[[NSString alloc] autorelease]; [pool release];

Reference Counting 요약 1 ) alloc, copy, new 들어가면 retain 했다고 생각하라 queue = [NSOperationQueue alloc] init]; // … [queue release]; 2 ) 결자해지 -> retain(alloc) 했으면 release 하라 [queue retain]; // … [queue release]; 3 ) 클래스 메서드가 객체를 생성해줄때는 autorelease 이니 신 경꺼라. img = [UIImage 4 ) 컬렉션 (NSMutableDictionary, NSMutableArray) 에 어객체 를 넣을때는 (retain) 뺄때는 (release) 자동호출된다..

Reference Counting 요약 5 ) 유저가 만든 메소드가 객체를 리턴해주는 경우는 autorelease 를 써서 보내자. ( 그냥 release 하면 큰일나지요 ) -(NSString*) findTopPlayer { NSString *ret = [[top objectAtIndex:0] copy]; [ret autorelease]; return ret; }

클래스 메소드와 Reference Counting - 한 번 더 요약 !!! 클래스 메소드 이름에 alloc 이 들어가는 경우 메소드 호출하는 곳에서 release NSString *text = [[NSString alloc] 클래스 메소드 이름이 안들어가는 경우 autorelease 니까 신경꺼 ! NSString *text = [NSString

Setter/Getter 와 dot notation 같습니다 ! // setter [myView setHidden:YES]; myView.hidden = YES; // getter BOOL isHidden = [myView hidden]; BOOL isHidden = myView.hidden; Property 만 잘 설정해주신 뒤에는 dot notation 으로 사용하시 면 됨