1 / 61

iOS Development Seminar

iOS Development Seminar. rodumani@sparcs.kaist.ac.kr 정 창제 2 013 06. iOS. Apple 의 mobile OS iPhoneOS3 -> iOS4 iPhone, iPad, iPod touch iOS61.3 Objective-C 2.0 Mac OS & XCode4 필요 오직 AppStore 만 존재 승인되지 않은 앱은 설치할 수 없다. iOS Developer Program. iOS SDK 는 무료로 이용가능

val
Download Presentation

iOS Development Seminar

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. iOS Development Seminar rodumani@sparcs.kaist.ac.kr 정 창제 201306

  2. iOS • Apple 의 mobile OS • iPhoneOS3 -> iOS4 • iPhone, iPad, iPod touch • iOS61.3 • Objective-C 2.0 • Mac OS & XCode4 필요 • 오직 AppStore만존재 • 승인되지않은앱은설치할수없다

  3. iOS Developer Program • iOS SDK는무료로이용가능 • 하지만 App의 Device Test, 배포, APNS, iCloud, 개발지원의이용을위해서는유료계정이필요 • 공부를위해서는훌륭한 Simulator 로도충분 • 개인개발자 $99, 기업용개발 $299 per year • http://developer.apple.com/ios

  4. iOS Developer Library • iOS 는 문서화가 굉장히 잘 되어 있다. • http://developer.apple.com/library/ios

  5. Objective-C 2.0 Tutorial : Start Developing iOS Apps Today https://developer.apple.com/library/ios/#referencelibrary/GettingStarted/RoadMapiOS/chapters/WriteObjective-CCode/WriteObjective-CCode/WriteObjective-CCode.html

  6. Objective-C 2.0 • C를기반으로 Smalltalk Style의메시지방식을추가한 OOP언어 • Next 사의 NeXTSTEP에서사용되었고후에애플이 Next를인수하여 Mac OS X을제작할때 NeXTSTEP이기반이되었기때문에애플의 Cocoa Framework의사용언어 • Objective-C 2.0은애플이 1.0에서개선한버전

  7. Objective-C 2.0 • C언어와엄격한하위호환성을가진다 • JAVA의 interface와같은 Protocol 지원, 다중상속불가 • Method 호출이아닌, Message 전달방식이기본철학 • MVC모델 • Garbage Collector 기능(ARC,Auto Reference Count)이지원되나 iOS에서는 5.0이상부터이용가능

  8. 파일구조 • .h : Header file. class,type,function,constant declaration • .m : Implementation file. Objective-C & C code. • .mm : Implementation file. Objective-C & C++ Code.

  9. 대표적자료형 • C의모든자료형 • NSNumber, NSInteger, NSDouble... • NSString • NSDictionary,NSSet,NSArray,... • NSURL,NSURLRequest,NSURLResponse…

  10. 대표적자료형 • Objective-C에서는 String을 @””로 감싼다 • @”asdfasdf” • iOS 6.0 이후부터 다음의 Syntax도 지원한다. • @"42” //[NSNumber numberWithInt:42]; • @[@"a",@"b”] //[NSArray arrayWithObjects:@”a”,@”b”,nil]; • @{@"key1":@"value1",@"key2":@"value2”}

  11. 클래스선언(.h)

  12. 클래스선언(.h) @interface classname : superclassname <Protocol1,Protocol2> { // 클래스변수 } + classMethod1; // 클래스메소드 +(return_type)classMethod2; +(return_type)classMethod3:(param1_type)param1_varName; -(return_type)instanceMethod1:(param1_type)param1_varName :(param2_type)param2_varName; // 인스턴스메소드 -(return_type)instanceMethod2WithParameter:(param1_type)param1_varName andOtherParameter:(param2_type)param2_varName; @end

  13. 클래스구현(.m) #import “MyClass.h” @implementation MyClass +(return_type)classMethod { // Implementation.. } -(return_type)instanceMethod { // Implementation.. } @end

  14. 포인터 • Static typing • MyClass *myObject1; // MyClass포인터로 object를 지정 • Dynamic typing • id myObject2; // id포인터(void 포인터)로 object를 지정 • id 는 특별한 포인터로 아무 Object나 가르킬 수 있다.

  15. 메시지 패싱

  16. 메시지패싱 • [Object method:message]; • [NSStringstringWithFormat:@"%@",@"rodumani"]; • [webViewloadRequest:[[NSURLRequest alloc]initWithURL: [[NSURLalloc]initWithString:@"http://m.naver.com"]]]; • NSURLRequest *request1 = [webViewrequest]; • NSURLRequest *request2 = webView.request;

  17. Property • In the general sense, property is some data encapsulated or stored by an object. It is either an attribute—such as a name or a color—or a relationship to one or more other objects. • Property는 setPropertyName, propertyName의 setter, getter가 자동 생성되며,dot notation을 통한 접근이 된다. • Property에는 getter, setter의 동작에 대한 Option을 줄 수 있다. • Accessor들은 Cocoa,Cocoa TouchFramework에서 KVC 등을 쓸수 있게 해주는 중요한 Element이다.

  18. PropertyOptions @property (nonatomic, copy) NSString *userName; nonatomic / atomic : atomic을 설정하면,Accessor Methods 에 lock을 사용하여 Multi Thread에 안전하게 처리한다. 대부분 고려하지 않아도 되는 변수들 이기 때문에 nonatomic으로 해줘서 성능을 향상시킨다. 기본값은 atomic이다. assign / copy / retain : Value를 Copy해서 return하거나 그 자체의 value를 return 한다.Retian의 경우 대입연산을 할 때마다 Reference Count가 증가한다.assign은 setter가 받은 값을 그대로 대입하는 행동을 한다. readwrite / readonly : readonly는 setter가 없다.

  19. Protocol • Protocol 이란,Protocol을 준수하는 Object는 Protocol에 선언된 함수를 실행함을 보장하며, 그 함수들을 이용한 작동을 한다는 뜻이다. • iOS에서 DelegatePattern은 매우 자주 사용되는 Pattern으로 Object가 적절한 행동을 취한 뒤,Delegate(위임자)에게 나머지 행동을 맡기는 것이다. • 나머지 행동으로 필요한 것을 대부분 Protocol에서 정의한다. @interface HelloWorldViewController : UIViewController <UITextFieldDelegate> Delegate Pattern :http://en.wikipedia.org/wiki/Delegation_pattern

  20. Category • 상속 없이 클래스를 확장하는 방법 • 기존 클래스에 내가 추가로 생성한 Method를 넣을 수 있다.

  21. Start Developing iOS App Today iOS앱 개발 시작을 설명하는 애플에서 작성한 문서 http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/RoadMapiOS/index.html%23//apple_ref/doc/uid/TP40011343

  22. iOS MVC Model

  23. *.h, *.m : ViewController 혹은 DataSource 의 Source Code • *.storyboard, *.xib : MVC모델에서 V에해당하는 Layout을정의하는파일. (android layout xml) • storyboard 는 Action에따른화면의전환을구성할수있는진보된 Layout 구성방법이다. (XCode 4.3 이상, iOS5 이상요구) storyboard : http://pinkyroman.tistory.com/4

  24. 이 세미나에서 앞으로 사용할 환경 • Mac OS X 10.8 Mountain Lion 기준 • Xcode 4.6.2 • iOS 6.1.3 • Deployment Target 6.0

  25. Hello World! • Xcode를 켜고 • Create a new Xcode project • 혹은 상단 메뉴바의 File-New-Project • iOS – Application – Single View Application • Product name : helloworld • Organization name : SPARCS • Company Identifier : org.SPARCS. • Class Prefix : Empty • Devices : iPhone • Use Automatic Reference Counting • StoryBoard는 사용안함

  26. 더블클릭!

  27. iOS Simulator • A당의 에뮬레이터와는 비교되지 않는 속도와 정확히 1:1대응되는 작동 • Hardware-Device에서 디바이스 종류를 선택 가능 • Hardware – Lock(⌘L), Home(⌘- Shift – H) 등의 홈버튼과 Lock도 지원 • 멀티테스킹 테스트도 가능 • Option키를 누르면 핀치줌 테스트 ( 화면 중심이 기준 ) • 단,iCloud, APNS 등의 하드웨어 의존적인 기능은 테스트 불가

  28. 곱셈 계산기

  29. 1.UI 작성

  30. View 와 Code의 연결

  31. 우클릭 마우스를 누르고 드래그

  32. 버튼이 눌려지면 불리울 함수 #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (strong, nonatomic) IBOutlet UITextField *lhsTextField; @property (strong, nonatomic) IBOutlet UITextField *rhsTextField; @property (strong, nonatomic) IBOutlet UIButton *calculateButton; @property (strong, nonatomic) IBOutlet UILabel *resultLabel; -(IBAction)calculate:(id)selector; @end

More Related