기본 콘텐츠로 건너뛰기

6월, 2013의 게시물 표시

TIP - Check ambiguous layout in Xcode debugger

How can I check auto layout issue of iOS application from Xcode? Easy.

Run your applicationPause by debuggerType the following command from debug console:(lldb) po [[UIWindow keyWindow] _autolayoutTrace]

You can see the trace from debug console such as:
*<UIWindow:0x9980df0> |   *<UIView:0x8eb2fd0> |   |   *<UISwitch:0x8eb31b0> |   |   |   <_UISwitchInternalViewNeueStyle1:0x8eb3540> |   |   |   |   <UIView:0x8eb3ac0> |   |   |   |   |   <UIView:0x8eb3840> |   |   |   |   <UIView:0x8eb3a10> |   |   |   |   |   <UIView:0x8eb38f0> |   |   |   |   <UIImageView:0x8eb3da0> |   |   *<UISlider:0x8eb61d0> - AMBIGUOUS LAYOUT |   |   |   <UIView:0x8eb9290> |   |   |   |   <UIView:0x8eb9af0> |   |   |   |   |   <UIView:0x8eb9bc0> |   |   |   |   <UIView:0x8eba490> |   |   |   <UIImageView:0x8eba6a0> |   |   |   |   <UIImageView:0x8eba540>
If you think type this long command is too tedious, please try to…

WWDC 2013 - Advances in Objective-C (404) Summary

Using a Framework#import model issueHeader fragilityNon-scalable compile timepre-compiled headers help significantly - maintenance burden / namespace pollution Modules solve these issues@import iAd;Doesn't need to parse headersLocal macro definitions have no effect on framework API Autolinking - don't need to "link binary with libraries"Selective import@import iAd.ADBannerView; Using Modules#import and #include automatically mapped to @importNo source changes requiredMac OS X Mail shows 40% faster compile time with modules - didn't manage pre-compiled headers well For old project, enables it manually through the GUIBuild Settings / Apple LLVM 5.0 - Language - Modules / Enable ModulesModules are not available for user framework Tools support for modernisationEdit / Refactor / Convert to Modern Objective-C Syntax … Explicit EnumsNS_ENUM, NS_OPTIONS Tagged PointersAdded to 64 bit CocoaFor small value like objects => stores object in the pointer itself => no m…

WWDC 2013 - Advanced debugging with LLDB Summary

Finding problemsDebug-only assertionsNSAssertNS_BLOCK_ASSERTIONS disables assertions in release buildsLog effectively with ASL (Apple System Log)ASL_LEVEL_EMERGASL_LEVEL_DEBUGUse hash tags like #web in log messagesHave switches for the heaviest logging (e.g. NSUserDefaults)Validate your program with XcodeWWDC 2010 Advanced memory analysis with instrumentsWWDC 2013 What's new in the LLVM compiler Stopping before problems occur BreakpointsStop at a source line:b MyView.m:4Stop at a method:b "-[MyViewA drawRect:]"Stop whenever any object receives a selector:b drawRect:Breakpoint commands run each time a breakpoint is hit (e.g. backtrace and continue)br co a> bt> c> DONECan be done also from GUI Find when a method is called on a specific instance(lldb) p id $myModel = self   --> create a persistent variable(lldb) b "-[MyModel dealloc]"(lldb) br m -c "self == $myModel"Focus on memory with watchpoints(lldb) watchpoint set variable self->_needS…

LLDB features and WWDC sessions

Let's check interesting LLDB (Xcode debugger) features maybe you don't know until yet.
Please find full documentation about LLDB from here.

AliasYou can make a few alias for commonly used commands. for example,(lldb) command alias bfl breakpoint set -f %1 -l %2(lldb) bfl Test.m 15You can store all aliases to ~/.lldbinit file. LLDB will read this file at startup.Regular expression aliasYou can use regex to make alias(lldb) command regex f "s/^([0-9]+)/frame select %1/"(lldb) f 12 --> frame select 12Type summaryIf you want to display summary for custom classes or structures, you can add type summary(lldb) type summary add --summary-string "x=${var.x} y=${var.y}" MyPointYou also can write a Python script that returns the string to be used as summary. Please see  LLDB documentationExpressionEvaluating generalized expression in the current frame(lldb) expr (int) printf("Print nine: %d", 5 + 4)Python scriptlldb has a built-in Python interpreter. you …

Java path from Mac OS X

Where is my Java SDK from Mac OS X with Oracle's JVM installing.
Easy way to find out it is running the below command from the terminal.
/usr/libexec/java_home
Can be a good idea to add JAVA_HOME to your .bash_profile file. such as
> vim ~/.bash_profile
Add the below line from vim.
export JAVA_HOME=`/usr/libexec/java_home`
Save file. Done.

Xcode 5 - comment for documentation

New feature of Xcode 5. You can document your own code as like the below:

/*! Add new message between source to destination timeline as empty name string
 * \param sourceId Source timeline entity ID
 * \param destId Destination timeline entity ID
 * \returns A newly created message instance
 */
- (ISMessage*)messageFromTimeline:(NSInteger)sourceId toTimeline:(NSInteger)destId;
You can use Doxygen format for documentation. Then you can see the documentation of this function from Xcode 5 UI (by using Quick Help or Option-Click). 

Very easy! The following comment styles are also possible.

/**   * Add new message between source to destination timeline as empty name string  * @author Wonil Kim  *  * @param sourceId Source timeline entity ID  * @param destId Destination timeline entity ID  * @return A newly created message instance  */ - (ISMessage*)messageFromTimeline:(NSInteger)sourceId toTimeline:(NSInteger)destId;
/// Add new message between source to destination timeline /// /// @param s…