H3 2011 iOS5 새로운 기능들의 프로젝트 적용 사례

Preview:

DESCRIPTION

 

Citation preview

모바일개발실��'iOS앱팀''���김윤봉

iOS5,새로운'기능들의프로젝트'적용'사례

&.5��3���

김'윤'봉|'YoonBong'Kim

iOS Developer

Eager for some knowledge constantly.

@y8k

¦n��C[¼�¶m��kV��e��LC

•https://www.facebook.com/iOSTip

•http://y8k.me

•http://dreamofblue.tistory.com

새로운'프로젝트,

의미있는'프로젝트로'

만들고'싶다!

}g��¹g§µ���� ��¿�·���

/�"��r¸

T��l�B®

­f�XZ�

iOS5의'새기능을

적용하겠습니다!

HMV�

??

추가된'기능들'중

어떤'기능들이

적합할까?

/�"���}g��RWb

/�25;*/�"��!�

#=/::+8":58?(5'8*9

���/:�58+�3'-+

�4.'4)+*�$��/:

"/8/

���))5;4:

�+=9�":'4*

�5:/,/)':/54

�+4:+8

!+3/4*+89

�"�� '89+8

/�25;*

서비스'레벨의'클라우드'서비스와는'다른'클라우드'서비스

사용자(User)의'특별한'통제가'필요치'않음

문서'및'Key-Value'데이터'저장

✓ 시스템에'녹아든'iCloud

VS.

�':'�":58'-+��;/*+2/4+�,58�/�25;*

http://developer.apple.com/icloud/documentation/data-storage/

✓ 데이터'스토리지'이용'가이드의'엄격한'적용

/Documents'디렉토리는'iCloud와'자동으로'동기화

임시'데이터는'/Library/Caches나'/tmp'디렉토리를'이용하도록'권고

iOS'5.0.1에서'“do'not'backup”'속성'추가

Storage'용량이'부족할'경우'/Library/Caches와'/tmp'디렉토리'내용'삭제

@*5�45:�(')1;6A

✓ 확장'파일'속성으로'제어

#include'<sys/xattr.h>

-'(BOOL)addSkipBackupAttributeToItemAtURL:(NSURL'*)URL'''{

''''const'char*'filePath'='[[URL'path]'fileSystemRepresentation];''''const'char*'attrName'='"com.apple.MobileBackup";

''''u_int8_t'attrValue'='1;'

''''int'result'='setxattr(filePath,'attrName,'&attrValue,'sizeof(attrValue),'0,'0);

''''return'result'=='0;

}

속성이'부여된'파일은'/Documents'디렉토리의'데이터라도'iCloud로'백업'안됨

파일'생성'직후에'호출

iOS'5.0.1'에서'추가됨

�!����;:53':/)�!+,+8+4)+��5;4:/4-�

✓ Objective-C'객체들의'수명을'자동으로'관리컴파일'레벨에서의'수행되며'자동으로'객체'수명'관리

retain,'release,'autorelease,'dealloc'등의'메소드'불필요

��!���¤���N¼��662+��QK

✓ Apple의'권고안CoreFoundation는'미적용

C'구조체'객체'포인터'대신'다른'객체(NSObject)에'포인터를'저장

객체와'객체가'아닌'타입'사이에'직접'캐스팅의'금지

NSAutorelease'대신'@autoreleasepool'와'중괄호({,})를'이용

assign,'retain'대신'weak,'strong'속성'이용

➡ 성능보다는'생산성의'향상

��³��H¾`�µ�²

��$#����))5;4:

✓ ACAccount'FrameworkACAccount,'ACAccountStore,'ACAccountType'클래스'제공

현재는'트위터'계정정보만'저장'및'사용'가능

구조상'다른'OAUTH'서비스도'적용이'가능

ACAccountStore

ACAccountType

#=/::+8

...Service'1 Service'2

Account

Account

...

Account

Account

...

Account

Account

...

/�"��~��µ�²�������ª´±����³�g��_

✓ 이전에'연동된'정보를'시스템으로'이동

oauth_token

oauth_token_secret

SYSTEM

���))5;4:

�8+*+4:/'2

-'saveAccount:withCompletionHandler:

✓ 시스템에'저장된'정보를'앱에서'사용하기

/�"��~��µ�²�������µ��J¦����~�|�

��8+7;+9:�))+99#5�))5;4:9&/:.#?6+�

=/:.�5362+:/54�'4*2+8�

9:58+�'))5;4:9

✓ Built-in'Composer'사용하기

µ�²��/�"��H¾��������53659+8�j���¼�µ��xUR

#&#=++:�53659+%/+=�54:8522+8

��)'4"+4*#=++:

#+>:��$!����3'-+

enum'TWTweetComposeViewControllerResult'{

'TWTweetComposeViewControllerResultCancelled,'TWTweetComposeViewControllerResultDone};

✓ 트위터'API'호출

µ�²��/�"��H¾�� ����#&!+7;+9:�j���¼�µ�²� ����

-'ACAccount':'Identifier

-'Request'URL

-'Parameters

#&!+7;+9:

��6+8,583!+7;+9:&/:.�'4*2+8�

�"��� '89+8

✓ JSON'Parser의'내장NSJSONSerialization'Class'의'추가

JSON'Data'to'Object

+'isValidJSONObject:

+'dataWithJSONObject:(id)obj'options:(NSJSONWritingOptions)opt''''''error:(NSError'**)error;+'JSONObjectWithData:(NSData'*)data'options:(NSJSONReadingOptions)opt''''''error:(NSError'**)error;

Stream'to'JSON

+'writeJSONObject:(id)obj'toStream:(NSOutputStream'*)stream'

'''''options:(NSJSONWritingOptions)opt'error:(NSError'**)error;+'(id)JSONObjectWithStream:(NSInputStream'*)stream''''''options:(NSJSONReadingOptions)opt'error:(NSError'**)error;

�54:'/4+8�%/+=�54:8522+8���

✓ Container'View'Controller

View'Controller의'구조가'Parent-Child로'확장

하나의'View'Controller가'여러'개의'View'Controller를'가짐

∈ '8+4:

�./2*

�54:'/4+8�%/+=�54:8522+8����

-'addChildViewController:

-'removeFromParentViewController:

-'transitionFromViewController:toViewController:

''duration:options:animations:completion:

-'willMoveToParentViewController:

-'didMoveToParentViewController:

✓ 추가된'메소드

//'child'추가/삭제

//'child간'전환'애니메이션

//'parent로'이동

$� '-+%/+=�54:8522+8��+35

✓ iBooks'페이지넘김'효과

$� '-+%/+=�54:8522+8��p

두 개의 View Controller가 필요컨텐츠가 정의된 View Controller

페이지를 제어할 UIPageViewController가 정의된 View Controller

컨텐츠 정의 View Controller이미지 설명과 정보, 페이지 번호 property 구현

UIPageViewController포함된 View Controller에 ContainerViewController로 정의

페이지 넘김 효과 정의

dataSource, delegate 정의

✓ UIPageViewController로'이미지'뷰어'구현

$� '-+%/+=�54:8522+8�P¨

CurrentBefore After

✓ UIPageViewController'구조각각은'동일한'구조의'ViewController

현재'index의'-1,'+1'위치의'ViewController'미리'준비되는'구조

idx'='current'-'1 idx'='current idx'='current'+'1

$� '-+%/+=�54:8522+8�*+2+-':+�3+:.5*9

��6'-+%/+=�54:8522+8��$� '-+%/+=�54:8522+8���6'-+%/+=�54:8522+8�

��*/*�/4/9.�4/3':/4-�������,/4/9.+*�

��68+</5;9%/+=�54:8522+89���"�88'?���68+</5;9%/+=�54:8522+89�

��:8'49/:/54�5362+:+*�������)5362+:+*

✓ Delegate'method

✓ DataSource'method��6'-+%/+=�54:8522+8��$� '-+%/+=�54:8522+8���6'-+%/+=�54:8522+8�

��</+=�54:8522+8�+,58+%/+=�54:8522+8��$�%/+=�54:8522+8���</+=�54:8522+8

��6'-+%/+=�54:8522+8��$� '-+%/+=�54:8522+8���6'-+%/+=�54:8522+8�

��</+=�54:8522+8�,:+8%/+=�54:8522+8��$�%/+=�54:8522+8���</+=�54:8522+8

$��'</-':/54�'8��')1-85;4*��3'-+

✓ $��'</-':/54�'8��$�#552�'8��

����tI�q«�¤�»R

UINavigationBar와'UIToolbar는'기본적으로'background에'image'적용'불가

UINavigationBar,'UIToolBar'의'background'에'이미지'적용

''iOS4'까지는'기본적으로'제공하는'메소드'없음

-'drawRect'메소드를'이용,'Layer를'이용'등의'방법'등'이용

-'기본'NavigationBar가'아닌'UIView를'이용하여'구현

''iOS5'에서'기본'메소드'지원

-'setBackgroundImage:'forBarMetrics':'UINavigationBar

-'setBackgroundImage:'forToolbarPosition'barMetrics':'UIToolBar

$$����$4/<+89'22?�$4/7;+��*+4:/,/+8�

✓ $���j��V�o�aV�*+68+)':+*��¦

단말기의'UDID를'얻는'[[UIDevice'currentDevice]'uniqueIdentifier]

-'단말기를'구분하기'위한'유일값

-'Deployment가'iOS'5.0'이상일'경우'컴파일'경고.

-'당장의'조치가'아닌'서서히'사용을'줄여나갈려는'의지로'해석됨

UUID의'사용'권장

-'앱을'사용하는'사용자의'유일한'값

-'유일값으로'UUID를'이용하여'생성하도록'권고

-'Core'Foundation'레벨에서의'API'존재

RR����E���R��À~V�

✓ $$��V�RR����E���Y

✓ RR����E��«¦»R��À~V�

�������!�""j���»����"�E��maV�sv��O¯�S�

g¬��ce�\e«G«m����«�ZB��°½�dlZ�\e­���¡Z�

/�25;*j�_RÃj���»FT�w^g�E��NkÀ��½�º����©£

프로젝트의

하위'호환성을'유지?!

간과했다!

»��u¥�ÂÄ�º�¼B�

✓ iOS5로'업데이트'한'사용자는'약'30%'수준

➡ 아직'iOS4의'사용자가'더'많다!

ÂÄ����À�]�y¢¼�PÁ�����

/�"�u¥��ci�zR

✓ /�"�u¥��ci�zR

[[[UIDevice'currentDevice]'systemVersion]'floatValue]'>='5.0f'로'분기

재사용'및'효율적인'코드'관리를'위해서'클래스'단위를'iOS'버전별로'나누자!

귀찮다고'생각하기보다'미리'해놓는다고'생각하자!

단,'새로운'기능이라고'다'좋은'것은'아니다!

�8)./:+):;8+

✓ 850+):��8)./:+):;8+9�&'84/4-

In'Xcode'4.x

$(ARCHS_STANDARD_32_BIT)'=='armv7

By'Xcode'3.x

Standard'=='armv6

Optimized'=='armv7

Hh

✓ ~{�j��À~��

최신'버전보다는'현재'사용자가'많이'사용하는'OS를'기준!

적용'가능한'부분은'일부의'적용으로'사용자에게'새로운'경험을'줄'수'있다는'점!

➡ 따라서'적절한'새로운'기능'조합과'함께'전략이'필요함!

✓ ��gj��À~��

새로운'무언가는'개발자의'활력소이다.

이'활력소를'스스로의'것만이'아닌'프로젝트에'적용함으로'보람을'느끼자!

부단히'노력하는'모습'어필!

➡ 배움을'게을리하지'말아야'할'개발자들의'필수덕목!!

D|¾XZ�scent07@paran.com

@y8k

Recommended