Wednesday, November 23, 2011

UIWebView anchor로 이동 방법

NSArray* urlArray = [urlString componentsSeparatedByString:@"#"];

if(1 < [urlArray count]){

        NSString *absoluteUrl = [urlArray objectAtIndex:0];

NSURL *url = [NSURL fileURLWithPath:absoluteUrl];

url = [NSURL URLWithString:[NSString stringWithFormat:@"#%@", [urlArray objectAtIndex:1]] relativeToURL:url];

NSURLRequest *req = [NSURLRequest requestWithURL:url];

[webView loadRequest:req];

}

URL에 anchor가 있는 경우 스트링에서 분리후 #%23으로 자동변환되지 않도록 직접 포맷팅해주면 앵커로 이동이 가능하다.

http://stackoverflow.com/questions/6691495/how-to-load-nsurl-which-contains-hash-fragment-with-uiwebview

Monday, November 21, 2011

XCod4 에서 크래쉬난 경우 콜스택을 보여주는 방법.

void uncaughtExceptionHandler(NSException *exception);

void uncaughtExceptionHandler(NSException *exception) {

NSLog(@"CRASH: %@", exception);

NSLog(@"Stack Trace: %@", [exception callStackSymbols]);

// Internal error reporting

}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

// Override point for customization after application launch.

NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);

return YES;

}

실제 서비스에서도 크래쉬에 대한 콜스택을 수거할 수 있도록 파일에 저장할 수 있다고 한다.

스택오버플로우에서 봤는데, 링크를 찾지 못하겠음...

Tuesday, November 1, 2011

GIT 충돌 해결

GIT 사용중 충돌 발생한 경우.

$ git pull

From xxxx

4cb74b1..d6ca118 master -> origin/master

Auto-merging xxx.xcodeproj/project.pbxproj

CONFLICT (content): Merge conflict in xxx.xcodeproj/project.pbxproj

Automatic merge failed; fix conflicts and then commit the result.

$ git status

# On branch master

# Your branch and 'origin/master' have diverged,

# and have 5 and 1 different commit(s) each, respectively.

#

# Unmerged paths:

# (use "git add/rm <file>..." as appropriate to mark resolution)

#

#        both modified: xxx.xcodeproj/project.pbxproj

#

충돌난 파일을 에디터로 열고 충돌을 해결한다.

그리고 커밋을 하면 아래 에러가 발생하고 커밋을 할 수 없다.

충돌난 파일을 git add 로 다시 추가하여도 동일한 에러가 발생한다.

Devs-MacBook-Pro:paperble_app dev$ git commit .

fatal: cannot do a partial commit during a merge.

이러한 경우 -i 옵션을 주면 stage에 되지 않은 파일을 커밋할 수 있다.

$ git commit . -i

http://dready.org/blog/2010/04/28/git-conflict-resolution/