[iPhone Dev] XCode 디버깅 시 메모리 맵 보기

No Comments

XCode에서 디버깅 할 때, 객체에서 우클릭하면 Memory Map을 볼 수 있는 메뉴가 있네요 ^^;;;

Ref

http://stackoverflow.com/questions/1209460/xcode-debugger-show-memory-address-for-primitive-types

[iPhone Dev] float double 모두 CGFloat

No Comments

네 그렇겠죠. 그냥 사소한 것들에서도 의미를 찾아보려고 합니다. 요즘은 ㅋㅋㅋ

 

iOS (그 땐 iPhone Dev 였죠. 그래서 지금도 전 포스트에 습관처럼 iPhone Dev라고 머릿 말을 붙입니다) 에선 부동 소수점 표현을 위해 CGFloat을 제공하죠.

일반적인 primitive type인 float, double도 쓸 순있지만, CGFloat를 사용하는 것인 naming convention 에도 좋고 자릿 수로 고민하지 않겠죠.

처음 iOS를 시작했을 땐, CGFloat의 Float 때문에 double 값에 쓸 땐 참 어색했습니다.

 

CGFloat aVal = 0.00000001;

NSLog(@"%.10f", aVal);

 

물론 iOS 내부에서도 각 math method에서 float와 double을 나누어 쓰고 NSNumber도  각 각의 타입에 따라 initiator가 있죠.

 

http://stackoverflow.com/questions/5352457/cgfloat-based-math-functions

http://stackoverflow.com/questions/5729004/how-to-print-a-double-with-full-precision-on-ios

 

[iPhone Dev] Xcode, Objective C의 맥에서의 문서화 (Doxygen Documentation)

No Comments

라이브러리 작업하는 것이 있어서 문서화를 하던 중, 애플의 문서화에 관한 문서에서 Header Doc과 관련 툴이 있어 (모양도 예쁘고 애플스러워) 사용해보려고 했으나 @property 등이 생성된 문서에 제대로 나타지 않아 포기하고 ( http://alones.kr/2302 )

결국 다시 Doxygen으로 작업을 했다.

Xcode의Help Docudment에 넣는 것이나, Xcode 빌드 스크립트 넣는 것, Graphviz 설정에 대해서 정리해본다.

[1] Doxygen 설치

Doxygen은 Doxygen 사이트에서 맥용을 받아서 설치하면 될 것이다.

( http://www.stack.nl/~dimitri/doxygen/ )


[2] Doxygen 문서화

Doxygen 사이트의 guide와 이 블로그의 다음 페이지 등을 보고 작성한다.

기본적인 사용 법: http://www.stack.nl/~dimitri/doxygen/docblocks.html

Group 사용 법: http://www.stack.nl/~dimitri/doxygen/grouping.html

전체적으로 작성 법에 대해 정리한 내 글: http://alones.kr/956

[3] Xcode의 빌드 스탭에 넣어서 Doxygen을 생성하고 Help Document에도 나오게 하기

기본적으로는 이 문서에 따라 build script를 추가해주면 되고, http://developer.apple.com/tools/creatingdocsetswithdoxygen.html

Script는 애플 페이지의 것이 아닌 아래 링크에 있는 것을 넣어주면 잘 동작한다.  http://stackoverflow.com/questions/3444379/scripting-xcode-documentation-with-doxygen-problems

[4] Doxygen UI 도구 사용

Xcode에서 해도 좋기는 하지만, 상세한 설정을 Doxygen Tool로 하고 빌드 시간을 뺏지 않는게 좋아서 UI 도구 사용도 괜찮은 것 같다.

맥용도 좋은 것 같다.

[5] Graphviz Dot을 이용한그래프

Doxygen이 자동 생성해주는 call, class diagram들을 Graphviz로 그리면 좀 더 좋을 것이다.

http://www.ryandesign.com/graphviz/ 에서 맥용 버전을 받아서 설치해주고

Graphviz Mac OS FAQ (http://www.ryandesign.com/graphviz/faq.php)에 나와있는 것처럼

Doxygen UI의 Expert tap을 선택해서 Dot 설정에서 DOT_PATH를 위 Graphviz의 설치 경로 ( e.g. /usr/local/graphviz-2.14/bin )을 설정해주면 된다.

[6] Doxygen으로 생성한 것을 chm과 같은 Docset을 생성하기

doxygen의 html들을 묶어주는 윈도우의 chm 파일을 맥에서는 바로 생성하기 힘들다.

대신 Docset을 만들면 하나의 파일로 doxygen을 만들 수 있고 xcode의 help document와 연결 (doxygen에 문서화한 class 등을 검색하면 나온다! ㅋㅋ)할 수 있다.

Xocde에서 빌드 스크립트로 바로 연결시키는 것은 편하지만 세세한 설정을 하기가 힘들어서 이 방법이 좋은 것 같다.

참고 문서는 이 문서 (https://ccrma.stanford.edu/~chanson9/tutorials/doxygen/doxygen.html )인데.. 조금 보다 Doxygen UI 도구의 설명 (좌측 하단)을 잘 읽어 봐도 간단히 할 수 있다.

1. Doxgyen UI의 expert tap에서 HTML의 GENERATE_DOCSET을 체크한다.

(필요한 부가 정보를 아래에 넣어도 되고 그냥 한 번 해 봐도 된다. 그리고 이 옵션의 좌측 하단 설명에 지금 설명하려는 것이 모두 잘 설명되어있다)

2. 그리고 Run으로 생성을 하면 doxygen html 들이 생신 폴더에 Makefile이 생성된다.

3. 콘솔에서 위 폴더로 이동해서 make install을 하면, 동일 폴더에 Doccse이 멋지게 생성되고 Xocde가 이용하는 폴더에도 복사되어 help document와 연결된다.

.

.

Appendix

Xcode Doxygen Build Script

#
# Build the doxygen documentation for the project and load the docset into Xcode
#
# Created by Fred McCann on 03/16/2010.
# http://www.duckrowing.com
#
# Based on the build script provided by Apple:
# http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
#
# Set the variable $COMPANY_RDOMAIN_PREFIX equal to the reverse domain name of your comany
# Example: com.duckrowing
#

DOXYGEN_PATH=/Applications/Doxygen.app/Contents/Resources/doxygen
DOCSET_PATH=$SOURCE_ROOT/build/$PRODUCT_NAME.docset

if ! [ -f $SOURCE_ROOT/Doxyfile]
then
  echo doxygen config file does not exist
  $DOXYGEN_PATH -g $SOURCE_ROOT/Doxyfile
fi

#  Append the proper input/output directories and docset info to the config file.
#  This works even though values are assigned higher up in the file. Easier than sed.

cp $SOURCE_ROOT/Doxyfile $TEMP_DIR/Doxyfile

echo "INPUT = $SOURCE_ROOT" >> $TEMP_DIR/Doxyfile
echo "OUTPUT_DIRECTORY = $DOCSET_PATH" >> $TEMP_DIR/Doxyfile
echo "RECURSIVE = YES" >> $TEMP_DIR/Doxyfile
echo "EXTRACT_ALL        = YES" >> $TEMP_DIR/Doxyfile
echo "JAVADOC_AUTOBRIEF        = YES" >> $TEMP_DIR/Doxyfile
echo "GENERATE_LATEX        = NO" >> $TEMP_DIR/Doxyfile
echo "GENERATE_DOCSET        = YES" >> $TEMP_DIR/Doxyfile
echo "DOCSET_FEEDNAME = $PRODUCT_NAME Documentation" >> $TEMP_DIR/Doxyfile
echo "DOCSET_BUNDLE_ID       = $COMPANY_RDOMAIN_PREFIX.$PRODUCT_NAME" >> $TEMP_DIR/Doxyfile

#  Run doxygen on the updated config file.
#  Note: doxygen creates a Makefile that does most of the heavy lifting.

$DOXYGEN_PATH $TEMP_DIR/Doxyfile

#  make will invoke docsetutil. Take a look at the Makefile to see how this is done.

make -C $DOCSET_PATH/html install

#  Construct a temporary applescript file to tell Xcode to load a docset.

rm -f $TEMP_DIR/loadDocSet.scpt

echo "tell application \"Xcode\"" >> $TEMP_DIR/loadDocSet.scpt
echo "load documentation set with path \"/Users/$USER/Library/Developer/Shared/Documentation/DocSets/$COMPANY_RDOMAIN_PREFIX.$PRODUCT_NAME.docset\"" >> $TEMP_DIR/loadDocSet.scpt
echo "end tell" >> $TEMP_DIR/loadDocSet.scpt

#  Run the load-docset applescript command.
osascript $TEMP_DIR/loadDocSet.scpt

exit 0

[iPhone Dev] Blocks에 대한 간단하고 괜찮은 튜토리얼 (tutorial)

No Comments

Selector를 잘 이용하면 function pointer와 동일하게 잘 쓸 수 있는데.. 너무 자바를 따라가서 만든 것 같기도하고..

암튼 blocks의 간단하고 괜찮은 tutorial이다. 머 그냥 Apple Dev Center의 Blocks 문서를 봐도 좋을 것 같고….

Using Blocks in iOS 4: The Basics

추가로 async jbo을 수행하는 아래 것도 알아야할 것이다.

How can I be notified when a dispatch_async task is complete?

[iPhone Dev] Objective C에서 c/c++ 함수를 부를려면

No Comments

.m 확장자를 .mm 으로 수정하면 돼죠~

ref: http://www.iphonedevsdk.com/forum/iphone-sdk-development/967-how-call-obj-c-functions-c-file.html

Older Entries