반응형
rss 아이콘 이미지
반응형

서치바에 초성 검색 기능을 넣을려고 자료를 찾다 보니

좋은 자료가 있어서 올립니다.
입력한 한글을 초성 중성 종성으로 분리하여 주는 소스인데
초성 검색에 사용하면 유용할 것 같네요.

초성검색

초성검색은 간단한 알고리즘이다. 
'ㄱㅇㅅ'로 검색하면 '강영수', '김영수', '김인수', '강연수' 등등 초성이 'ㄱㅇㅅ'으로 시작하는 모든 단어를 찾아주는 것이다. 
핸드폰에서 전화번호를 검색할때 많이 사용하는 기능이다. 
이 검색의 장점은 명백하다.

 
첫째 검색어의 타이핑수가 줄어든다.
둘째 검색의 성공확률이 높아진다. (애매모호한 검색어로 원하는 결과를 찾을수 있다. )
 
한국어는 초성, 중성, 종성 또는 초성,중성 으로 한글자가 만들어진다. 따라서 모든 글자에 포함되어 있는 초성으로 검색한다는것은 대략 
타이핑수를 1/2 ~ 1/3로 줄여준다.

 
둘째 장점은 좀더 흥미롭다. 한국어에서 목소리로 전달되는 단어중 잘못들을 확률이 높은 것은 중성, 종성이다. 굳이 정밀하게 따져보지 
않아도 누군가에게 이름을 들었는데 잘못들은 부분이 초성이었는지 중성 또는 종성 부분이었는지 생각해보면 쉽게 알수 있다.  따라서 정확하게 알지 
못하는검색어로 내가 원하는 결과를 얻고자 할때도 초성검색은 유용하게 쓰일수 있다.
초성검색을 실제로 이용하려면 약간의 작업이 필요하다. 대략적으로 살펴보면 우선 기존에 존재하는 데이타 베이스에 초성값을 계산해서 
입력해둘 필요가 있다. 그렇지 않으면 매 검색마다 기존 데이타의 초성값을 계산해야 할것이다. 두번째 작업은 사소한 것인데 한글자판에서 'ㄱ', 
'ㅅ'을 연속으로 입력해보면 'ㄳ'값이 입력된다. 이건 유효하지 않은 초성이다. 'ㄳ'은 종성값이지 초성값이 아니므로 이런값이 입력되지 않도록 
만들어주어야 한다. 'ㄳ'을 내부적으로 'ㄱㅅ'으로 바꾸어주던지 아예 'ㄳ'값이 입력되는 것을 막아도 된다.  물론 'ㄱ'을 입력하고 옆으로 
이동해서 'ㅅ'을 입력하는 방법으로 해결해도 되지만 사용자 인터페이스가 후지게 된다. 또한 타이핑도 늘어난다

 

- (NSString *)GetUTF8String:(NSString *)hanggulString {

NSArray *chosung = [[NSArray alloc]initWithObjects:@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",nil];

NSArray *jungsung = [[NSArray alloc]initWithObjects:@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",nil];

NSArray *jongsung = [[NSArray alloc]initWithObjects:@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@" ",@"",@"",nil];

NSString *textResult = @"";

for (int i=0;i<[hanggulString length];i++) {

NSInteger code = [hanggulString characterAtIndex:i];

if (code >= 44032 && code <= 55203) {

NSInteger uniCode = code - 44032;

NSInteger chosungIndex = uniCode / 21 / 28;

NSInteger jungsungIndex = uniCode % (21 * 28) / 28;

NSInteger jongsungIndex = uniCode % 28;

textResult = [NSString stringWithFormat:@"%@%@%@%@", textResult, [chosungobjectAtIndex:chosungIndex], [jungsung objectAtIndex:jungsungIndex], [jongsung objectAtIndex:jongsungIndex]];

}

}

return textResult;

}


- (void)loadView {

[super loadView];

NSLog@"%@", [self GetUTF8String:@"투덜이"]);

}

반응형
반응형
    UILabel *label;
    NSString *a;
    label = [[UILabel alloc] init];      
    label.frame = CGRectMake(0, 39, 150, 20);
    label.textAlignment = UITextAlignmentCenter;
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont systemFontOfSize:20];
    label.textColor = [UIColor blackColor];
    a = @"들어갈 텍스트";
    label.text = a;
    [self.view addSubview:label];
    [label release];
   
    실행결과 : 들어갈 텍스트


    label.text = [a stringByReplacingOccurrencesOfString:@"들어" withString:@"없어지던가" ];

   실행결과 : 없어지던가갈 텍스트
 

   참 쉽죠잉 ~

반응형

[IB없이 개발하기]UIImage 넣기

개발/개발팁 2011. 5. 9. 12:10 Posted by 법당오빠
반응형
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"넣고싶은 이미지.png"]];
    [imageView setFrame:CGRectMake(0, 0, 320, 460)];
    [self.view addSubview:imageView];

반응형

[IB없이 개발하기]UIButton 넣기

개발/개발팁 2011. 5. 4. 17:26 Posted by 법당오빠
반응형
UIImage *stampImg;

CGRect frame = CGRectMake(5 + (80 * (i % 4)), (70 * (i / 4)), 60, 60);
stampbtn = [[UIButton alloc] initWithFrame:frame];

stampImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"emo_%02d", i + 1] ofType:@"png"]];
[stampbtn addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[stampbtn setBackgroundImage:stampImg forState:UIControlStateNormal];
[stampbtn setBackgroundImage:stampImg forState:UIControlStateHighlighted];
[stampImg release];
[stampScoll addSubview:stampbtn];
반응형
반응형
- (void)_hideKeyboardRecursion:(UIView*)view {
    if ([view conformsToProtocol:@protocol(UITextInputTraits)]){
        [view resignFirstResponder];
    }
    if ([view.subviews count]>0) {
        for (int i = 0; i < [view.subviews count]; i++) {
            [self _hideKeyboardRecursion:[view.subviews objectAtIndex:i]];
        }
    }
}

- (void) hideKeyboard {
    UIWindow *tempWindow;
    for (int c=0; c < [[[UIApplication sharedApplication] windows] count]; c++) {
        tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c];
        for (int i = 0; i < [tempWindow.subviews count]; i++) {
            [self _hideKeyboardRecursion:[tempWindow.subviews objectAtIndex:i]];
        }
    }
}

이렇게 하면 모든뷰를 검사하여 키보드를 숨겨줍니다

반응형

'개발 > 개발팁' 카테고리의 다른 글

SVN 오류 해결법  (0) 2011.06.21
[IB없이 개발하기]UIImage 넣기  (0) 2011.05.09
[IB없이 개발하기]UIButton 넣기  (0) 2011.05.04
[IB없이 개발하기] UILabel 붙이기  (0) 2011.05.04

개발용 컴퓨터와 아이폰 준비하기

개발/iOS 2010. 7. 22. 11:19 Posted by 법당오빠
반응형
이폰, 이이팟 터치(이하 장치)상에서 어플리케이션을 테스트하기 위해서는,
아이폰 OS 개발용 컴퓨터와 장치를 설정해야만 한다.

아이폰 어플리케이션을 빌드할 수 있기 위해서 개발용 컴퓨터와 개발 장치에 꼭 있어야 하는것들을 나열했다.

  - keychain내에 개발 증명서
  - 예비 프로파일
  - 아이폰 OS 2.0 이나 이후 버젼

 

다음은 아이폰 개발용 컴퓨터와 개발 장치를 설정하기 위해 따라야만 할 과정들이다.

1. 어플리케이션 ID 설정하기.

2. 프로그램 포털에 장치 등록하기.

3. 장치상에 아이폰 OS를 인스톨하기(이미 되어 있겠죠).

4. 개발 증명서를 획득하기.

5. keychain에 개발 증명서를 추가하기.

6. Xcode에 예비 프로파일을 추가하기.

7. 개발용 아이폰에 예비 프로파일을 인스톨하기. 


아래그림은 위 과정의 연관성을 알아보기 쉽게 보여준다.

iphone_dev_digital_assets

 

1. 어플리케이션 ID 설정하기

  아이폰 개발자 프로그램의 멤버가 되면 프로그램 포털에서 어플리케이션 ID를 설정해야만 한다. 
  아이폰 OS는 당신이 만든 어플리케이션을 식별하기 위해 어플리케이션 ID를 사용한다. 
  아이폰 어플리케이션 ID는 10개 문자 묶음으로 생성되는 식별자와 묶음 식별자로 구성된다. 
  묶음 식별자(번들 아이텐티파이어)는 어플리케이션 하나 혹은 어플리케이션 그룹을 식별할 수 있다. 
  이는 MyApp라는 하나의 어플리케이션을 식별하는 아이폰 어플리케이션 ID의 예이다.

   GFWOTNXFIY.com.mycompany.MyApp

  

아래에서 보여지는 것처럼 묶음 식별자에서 어플리케이션 이름 대신 * 문자를 사용하여, 관련 어플리케이션들 사이에서
하나의 어플리케이션 ID를 나눌수 있게 한다.

  GFWOTNXFIY.com.mycompany.myappsuite.*

  


2. 프로그램 포털에 장치 등록하기.


  포털에 개발 장치를 등록하기 위해서는 Xcode를 실행하고 Organizer 윈도우(Window > Organizer)를 연다. 
  개발 장치를 꼽고 장치 리스트에서 장치를 선택한다. 
  아래 그림처럼, Summary(요약) 탭의 식별자 텍스트 필드에서 장치 UDID를 복사한다. 

Organizer_ID.jpg
  이제 프로그램 포털에 가서 등록하자.


 
3. 장치상에 아이폰 OS를 인스톨하기(이미 되어 있겠죠).


  아이폰 OS는 개발 대상,SDK버전에 따라 선택적이다.


4. 개발 증명서를 획득하기.

  Xcode는 테스팅용 장치에 어플리케이션을 업로드하기 전에 코드-서명하기 위해 당신의 개발 증명서를 사용한다

  
   4-1. Keychain Access 를 실행하자.

   4-2. Common Name 필드에 이름을 기입하자.


   4-3. 증명서 정보 윈도우에서 "Request is" 그룹내에, "Saved to disk" 옵션을 선택하자.


   4-4. "Let me specify key pair information." 을 선택하자.


   4-5. Continue 클릭.


   4-6. CSR 파일 위치로 컴퓨터로 선택하자.


   4-7. Key Pair Information 탭에서 키 크기로 2048, 알고리즘으로 RSA를 선택하자.


   4-8. CSR 파일을 컴퓨터로 저장한다.


   4-9. CSR 파일을 텍스트 에디터에서 열어, 닫기 태그를 포함한 전문을 복사하자.


   4-10. 프로그램 포털에 CSR을 제출하자.

 

   CSR이 팀 어드민에 의해 증명된 뒤, 프로그램 포털에서 개발 증명서를 다운로드 받을 수 있다.
   개발 증명서가 keychain에서 없어지면, 프로그램 포털에서 다시 다운로드 받으면 된다.

 

5. keychain에 개발 증명서를 추가하기.

   개발 증명서를 더블 클릭하여 Keychain Access 어플리케이션 실행한 후

   Add Certificates 다이얼로그에서, Keychain 이  "login"으로 설정되었는지 확인하고 OK 클릭

 

6. Xcode에 예비 프로파일을 추가하기.

   프로그램 포탈에서 팀 어드민에게 예비 프로파일을 생성 요청하고 다운받을수 있다.

   개발 장치에 예비 프로파일을 추가하기 위해 Organizer 를 사용한다. 
   예비 프로파일을 Xcode에 추가하기 위해서는 Dock 안의 Xcode 아이콘으로 예비 프로파일을 드래그하고 
   Xcode를 재 시작한다.

 

7. 개발용 장치에 예비 프로파일을 인스톨하기.

   Organizer 윈도우를 열면 Summary 탭에 Provisioning 섹션에 예비 프로파일이 보일 것이다.

   안보이면 6번 과정을 다시 시도해봐야 한다.

   장치를 꼽고, 장치 리스트에서 선택한다. 
   예비 프로파일을 인스톨하기 위해 provisioning profile 옆의 체크박스를 클릭해야 한다. 
   정상적으로 인스톨되면, provisioning profile 옆의 체크박스에 체크마크가 나타날 것이다.

   만약 체크마크가 나타나지 않으면
   예비 프로파일이 장치 UDID, 개발 증명서, 합법적인 어플리케이션 ID를 포함하고 있는지 확인해야 한다.

 

이상으로 개발용 컴퓨터와 아이폰 준비하기가 모두 끝났습니다.

 

P.S.
    그림과 함게 설명을 다시해야 겠다는 맘이 드네요. 시간이 허락하는데로 보완해서 올려드리겠습니다.

반응형

아이폰 오픈소스 모음들입니다

개발/iOS 2010. 7. 12. 13:15 Posted by 법당오빠
반응형
<그래프>
http://code.google.com/p/core-plot/
 
<달력>
http://ved-dimensions.blogspot.com/2009/04/iphone-development-creating-native_09.html

<sqlite>
http://code.google.com/p/pldatabase/ (BSD license)

<계산기>
http://code.google.com/p/hpcalc-iphone/ (GPL V2 license)

<트위터 클라이언트>
http://github.com/blog/329-natsuliphone-iphone-twitter-client
http://code.google.com/p/tweetero/

<facebook>
http://github.com/facebook/three20

<rss reader>
http://code.google.com/p/iphone-simple-rss-aggregator/

<ebook reader>
http://code.google.com/p/iphoneebooks/

<blog>
http://iphone.wordpress.org/

<백업, 동기화>
http://www.funambol.com/solutions/iphone.php
http://code.google.com/p/gris/ (구글 리더 동기화)

<time tracking>
http://github.com/freshbooks-addons/freshbooks-iphone-project

<게임>
http://code.google.com/p/cocos2d-iphone/
http://code.google.com/p/tris/ (테트리스)
http://code.google.com/p/mintgostop/ (고스톱)
http://www.joystiq.com/2009/03/24/carmack-releases-open-source-wolfenstein-for-iphone/

<google toolbox>
http://code.google.com/p/google-toolbox-for-mac/

<택배>
http://kldp.net/projects/taekbae/src

<이미지 프로세싱>
http://code.google.com/p/simple-iphone-image-processing/

<증강현실>
http://www.iphonear.org/

<coverflow 대체 구현>
http://apparentlogic.com/openflow/

< 정규표현식 라이브러리>
http://blog.mro.name/2009/09/cocoa-wrapped-regexh/
http://regexkit.sourceforge.net/RegexKitLite/

<라이브러리 : JSON, DOM XML, Google Data APIs, Twitter, Flick, Game Engines, Unit Testr>
http://www.codingventures.com/2008/12/useful-open-source-libraries-for-iphone-development/

<기타>
http://open.iphonedev.com/
http://joehewitt.com/post/the-three20-project/

출처 : http://cafe.naver.com/mcbugi/30423
반응형

아이폰 4.0 다운그레이드하기

개발/iOS 2010. 6. 17. 09:35 Posted by 법당오빠
반응형

Think you’ve made a mistake by upgrading your iPhone or iPod touch to the latest and greatest iPhone OS beta? iPhone OS 4.0 can be a little buggy and may not even work nicely with some applications, but that didn’t stop some from making the leap. Apple intended for this beta version of the iPhone OS to be strictly for developers and it shows. We're going to show you how to return your device back to OS 3.1.3 far away from those beta bugs.

We suggest reading this how-to in its entirety before proceeding with this process. We successfully downgraded our device from 4.0 to 3.1.2 on multiple iPhone 3GS models, but haven’t tried this process on an iPhone 3G or iPod touch.

 

Disclaimer: Your mileage may vary, so proceed at your own risk. Mac|Life takes no responsibility if you brick your device.

Difficulty Level: Medium

What You Need:
- An iPhone Running OS 4.0
- A Mac
- iRecovery v. 1.3 for Mac
- Libusb Library


Step 1 - Download iRecovery and Libusb
You’ll need two pieces of software in order to downgrade your device from OS 4.0 back to OS 3.1.3. You can download iRecovery by clicking here (direct-download link). You can download Libusb by clicking here (direct-download link).

You can install Libusb by unzipping and running the installer. Unzip and place the iRecovery script on your Desktop.


Step 2 - Sync Your iPhone
The first part of any OS restore should be to backup and sync your iPhone data. Connect your device to iTunes and click the lovely Sync button. Depending on how many changes you have, this could take a while so get a snack and watch the status bar climb to the finish line.

iPhone OS 4.0 doesn’t allow you to backup your device, so anything that’s not synced over to iTunes will be lost.


Step 3 - Start The Restore
Press alt/option and click the Restore button in iTunes. This will bring up a dialog that will allow you to manually select your iPhone OS firmware. Navigate to User/Library/iTunes/iPhone Software Updates/ and select “iPhone2,1_3.1.3_7E18_Restore.ipsw”. Click Choose and the OS restore process will begin.


If you don’t have this version of the iPhone OS software, then you’ll need to download it by clicking your version below. Then repeat this process by navigating to the download location and selecting it. Click Choose and the OS restore process will begin.

Download iPhone OS 3.1.3 for iPhone 3G

Download iPhone OS 3.1.3 for iPhone 3GS

Your device will most likely show the error "1015" when it is restoring the firmware. Ignore this error as we will take care of it in the next step.


Step 4 - Use iRecovery to complete restore
Now we’re going to use iRecovery to complete the restore process and get around the firmware upgrade problem that we encountered in the previous step.

To do this, launch Terminal (Applications/Utilities) and type in the following commands:

cd Desktop

./iRecovery -s

setenv auto-boot true

saveenv

fsboot

exit


After a few seconds, you can disconnect your iPhone and power it off manually by pressing the power and home buttons simultaneously. Now when you power up your iPhone, you should see the standard connect to iTunes image.

You can now safely connect your iPhone to iTunes.


Step 5 - Restore Your iPhone from a Backup
When you connect your iPhone back to iTunes, you’ll have two options: Set up as a new iPhone or Restore from the backup of. If you’re restoring from a previous backup, select it from the drop down menu and click Continue. If not, select Set up as a new iPhone and continue the on-screen instructions. 


Your device restore will take a few minutes to complete, so you may want to grab a snack and watch the status bar for entertainment (or not, your choice).

Step 6 - Relax You’re Back to 3.1.3
You can now breathe a sigh of relief and pat yourself on the back. Your iPhone has now been safely restored back to its previous OS version (3.1.3). If you’re into jailbreaking, you can now re-jailbreak your device following the same process you followed before.

Process via Gadgets DNA

 모르시면 댓글주세요

반응형

아이폰 환불 받는 방법

카테고리 없음 2010. 6. 8. 18:20 Posted by 법당오빠
반응형
아이폰 환불 받는 방법

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
나도좀 ...

반응형