출처: http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=7462&MAEULNO=911&no=51672&page=1

최근 수신한 메일이 있으면 iPhone, iPod touch 메일 아이콘에 빨간색 동그라미 안에 있는 숫자를 보실 수 있습니다.

최근 수신한 이메일 개수를 보여주기 위한 배지(Badge)인데, 최근 수신한 데이터나 최근 등록한 데이터가 있을 때 보여주게 하면 시각효과가 좋습니다.

방법은 아주 간단합니다.

You can see number inside circle in red when you've got email recently on iPhone, iPod touch mail application.
It calls "Badge" that shows quantity of your recent received email. If there are some new received data or registered data,
visual effect(for recognition) will be good.

How-to use the "Badge" is easy.

 

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:99];

 

 

 

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:123456];

 

 

Badge Number를 0으로 하면 뱃지가 사라집니다.

Setting "setApplicationIconBadgeNumber" to 0 (zero) will make disappeared the "Badge".

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

 

App을 종료하기 전에 위 코드를 실행해주면 종료후 iPhone 화면에 배지가 달린 아이콘을 보실 수 있습니다.

If you run above code before closing the application, you may see an icon with badge.

(추가)

위 내용은 델리게이트의 applicationWillTerminate: 메소드에 적용 시 iOS 4.0 이전에서는 이상이 없습니다.
4.0 이후라면 어플이 백그라운드로 진입 시 어떻게 할지 정한 후 (info.plist 파일에서 +누른 후 선택)
체크 한 경우에는 상관이 없고, (멀티 태스킹 미지원으로 설정)
체크 해제한 경우에는 어플이 백그라운드로 갈 때의 메소드에도 넣어주시면 됩니다. (멀티 태스킹 지원, 두 메소드 모두에 넣기)

(Addition)

Above article is for lower version than iOS 4.0 (support multi-tasking function).
Using higher iOS version(support multi-tasking function, after iOS 4.0), you must consider a matter in all its aspects whether you will use badge on multi-tasking environment.
You can set up on info.plist file. Add new option to info.plist on xcode by clicking + button.
Select Application does Not run in Background option.
Checking that option will not support multi-tasking, unchecking will support.
Checking that option is equal to this article, unchecking may make some code to application will run in background methods.

Posted by 독뽀
,