기본 콘텐츠로 건너뛰기

라벨이 XCode인 게시물 표시

iOS/swift - segue 연결 후 중간에 가로채기 하고자 할때 : shouldPerformSegueWithIdentifier

segue로 storyboard를 연결해 놓고 특정 조건일 때 해당 segue로 연결을 막고 싶은 경우가 있다. 가령 특정 메뉴를 들어가고자 할땐 로그인이 되있지 않다면 로그인 화면으로 유도하려면 segue를 중간에 가로채야 한다. UIViewController 안에서 shouldPerformSegueWithIdentifier 를 사용하여 구현할 수 있다. NeedLoginSegue 로 이동할 경우 사용자 정보(  checkUserInformation ( userDefaults ) )가 false면 LoginSegue 를 열게 하는 코드는 다음과 같다.     override func shouldPerformSegueWithIdentifier(identifier: String , sender: AnyObject ?) -> Bool {         if identifier == "NeedLoginSegue" {              if checkUserInformation ( userDefaults )== false {                 self . performSegueWithIdentifier ( "LoginSegue" , sender: nil )             }             return false         }         return true     } unwind와 함께 빈번하게 쓰는 패턴이니...

Xcode Log - Label / Attributed Text - Replace

        let mutableString: NSMutableString = ( resultLabel . attributedText as ! NSMutableAttributedString ). mutableString         mutableString. replaceOccurrencesOfString ( "@1" , withString: "109" , options:  NSStringCompareOptions .LiteralSearch , range: NSMakeRange ( 0 , mutableString. length )) 결국 이 두 줄의 코드. AS3 할때도 이런 경우가 있었는데  HTML 형식으로 formatting한 label을 다룰때 생각보다 간단하지 않았다. 물론 해결하고 나니 속 시원했었지만. 이게 다 저 @1 부분을 replace 하려고 시작한 일이었다. 조금 더 다양한 가능을 보려고 손을 좀 더 보았다. Xcode 에서 이걸 직접 살펴보았다.                                 <attributedString key = "attributedText" >                                     <fragment content = " 이거이 사람이 할 짓이 아닌가 봅니다 . " >           ...

Xcode Key binding

1. 우상단 컨트롤들 왼쪽부터  Show the Standard View - Cmd + Enter Show the Assistant View - Cmd + Option + Enter Show the Version Editor - Cmd + Option + Shift + Enter 왼쪽부터 Hide or show the Navigation - Cmd + 0   Hide or show the Debug Area - Cmd + Shift + Y Hide or show the Utilities - Cmd + Alt + 0   2. Storyboard Hide or show Document Online - 바인딩 없음(Cmd + 9 로 설정)  3. 우측 상단 바로 아래 Inspectors 왼쪽부터 Show the File inspector - Cmd + Shift + 1 Show Quick Help inspector - Cmd + Shift + 2 Show the Identity inspector - Cmd + Shift + 3 Show the Attributes inspector - Cmd + Shift + 4 Show the Size inspector - Cmd + Shift + 5 Show the Connections inspector - Cmd + Shift + 6 4. 우측 하단 Library 왼쪽부터 Show the File Template Library - Cmd + Ctrl + Option + 1 Show the Code Snippet Lib...

XCode OS X Application : Drag & Drop 후 파일 처리

개인적으로 필요한 유틸이 있어서 appleScript 로 만들까하다가 XCode 4.4 로 OS X Application 을 만들어 본 적이 없어서 Drag & Drop, Pipe, File 처리 같은 걸 해봤다. xib 에 드래그할 대상인 NSImageView 를 놓고 그 NSImageView 를 Customize 한 NSCImageView 를 만들어서 구현했다. performDragOperation 이벤트에서  NSPasteboard  *paste = [sender draggingPasteboard]; 로 NSPasteboard 객체에 드래그 한 것들을 가지고 NSFilenamesPboardType 인것들을 타입으로 추출하여 NSData로 받았다. NSArray *fileArray = [paste propertyListForType : @"NSFilenamesPboardType" ]; 파일 목록은 propertyListForType으로 string array 를 받을 수 있다. http://borkware.com/quickies/one?topic=nstask shell 실행하고 결과 stdout 을 받는 것 처리하는데 위의 링크를 참조했다.   NSTask *task = [[ NSTask   alloc ]  init ];   [task  setLaunchPath : @" <SHELL COMMAND> " ]; NSTask 를 setLaunchPath 메서드를 사용하여 콜할 커맨드를 지정하고   [task  setArguments :[ NSArray   arrayWithObjects : <@args> , file,  nil ]]; N개의 argument 를 지정   NS...