Sep 04

UIView의 setNeedDisplay를 불러도 view가 update되지 않는 경우가 있다. (화면을 슬쩍 건드려야한다든지..)

특히 다른 thead에서 요청했을 때 더 잦은데, 이 경우 performSelectorOnmainThread를 쓰면 상황이 나아진다.

(그리고 생각보다 NSOperationQueue의 operation 수를 좀 늘려도 도움이 된다.)

[imageView performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
Tagged with:
Sep 02

서버 등에서 받은 NSData가 NSUTF8StringEncoding나 NSASCIIStringEncoding 인코딩으로 NSString을 생성해도 한글이 제대로 보이지 않을 때는 0×80000840 으로 인코딩 하면 된다.

NSString* aString = [[[NSString alloc] initWithData:receivedData encoding:0x80000422] autorelease];

아래 표가 NSString.h에서 정의하고 있는 encoding인데

enum {
NSASCIIStringEncoding = 1,        /* 0..127 only */
NSNEXTSTEPStringEncoding = 2,
NSJapaneseEUCStringEncoding = 3,
NSUTF8StringEncoding = 4,
NSISOLatin1StringEncoding = 5,
NSSymbolStringEncoding = 6,
NSNonLossyASCIIStringEncoding = 7,
NSShiftJISStringEncoding = 8,          /* kCFStringEncodingDOSJapanese */
NSISOLatin2StringEncoding = 9,
NSUnicodeStringEncoding = 10,
NSWindowsCP1251StringEncoding = 11,    /* Cyrillic; same as AdobeStandardCyrillic */
NSWindowsCP1252StringEncoding = 12,    /* WinLatin1 */
NSWindowsCP1253StringEncoding = 13,    /* Greek */
NSWindowsCP1254StringEncoding = 14,    /* Turkish */
NSWindowsCP1250StringEncoding = 15,    /* WinLatin2 */
NSISO2022JPStringEncoding = 21,        /* ISO 2022 Japanese encoding for e-mail */
NSMacOSRomanStringEncoding = 30,

NSUTF16StringEncoding = NSUnicodeStringEncoding,      /* An alias for NSUnicodeStringEncoding */

#if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED || __IPHONE_2_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
NSUTF16BigEndianStringEncoding = 0x90000100,          /* NSUTF16StringEncoding encoding with explicit endianness specified */
NSUTF16LittleEndianStringEncoding = 0x94000100,       /* NSUTF16StringEncoding encoding with explicit endianness specified */

NSUTF32StringEncoding = 0x8c000100,
NSUTF32BigEndianStringEncoding = 0x98000100,          /* NSUTF32StringEncoding encoding with explicit endianness specified */
NSUTF32LittleEndianStringEncoding = 0x9c000100        /* NSUTF32StringEncoding encoding with explicit endianness specified */
#endif
};

한글은 아래 표에 나와있다.

* NSString *

Western (Mac OS Roman) 0x1e
Japanese (Mac OS) 0×80000001
Traditional Chinese (Mac OS) 0×80000002
Korean (Mac OS) 0×80000003
Arabic (Mac OS) 0×80000004
Hebrew (Mac OS) 0×80000005
Greek (Mac OS) 0×80000006
Cyrillic (Mac OS) 0×80000007
Devanagari (Mac OS) 0×80000009
Gurmukhi (Mac OS) 0x8000000a
Gujarati (Mac OS) 0x8000000b
Thai (Mac OS) 0×80000015
Simplified Chinese (Mac OS) 0×80000019
Tibetan (Mac OS) 0x8000001a
Central European (Mac OS) 0x8000001d
Symbol (Mac OS) 0×6
Dingbats (Mac OS) 0×80000022
Turkish (Mac OS) 0×80000023
Croatian (Mac OS) 0×80000024
Icelandic (Mac OS) 0×80000025
Romanian (Mac OS) 0×80000026
Keyboard Symbols (Mac OS) 0×80000029
Farsi (Mac OS) 0x8000008c
Cyrillic (Mac OS Ukrainian) 0×80000098
Western (Mac VT100) 0x800000fc
Unicode™ (UTF-16) 0xa
Unicode™ (UTF-8) 0×4
Western (ISO Latin 1) 0×5
Central European (ISO Latin 2) 0×9
Western (ISO Latin 3) 0×80000203
Central European (ISO Latin 4) 0×80000204
Cyrillic (ISO 8859-5) 0×80000205
Arabic (ISO 8859-6) 0×80000206
Greek (ISO 8859-7) 0×80000207
Hebrew (ISO 8859-8) 0×80000208
Turkish (ISO Latin 5) 0×80000209
Nordic (ISO Latin 6) 0x8000020a
Thai (ISO 8859-11) 0x8000020b
Baltic Rim (ISO Latin 7) 0x8000020d
Celtic (ISO Latin 8) 0x8000020e
Western (ISO Latin 9) 0x8000020f
Latin-US (DOS) 0×80000400
Greek (DOS) 0×80000405
Baltic Rim (DOS) 0×80000406
Western (DOS Latin 1) 0×80000410
Central European (DOS Latin 2) 0×80000412
Turkish (DOS) 0×80000414
Icelandic (DOS) 0×80000416
Arabic (DOS) 0×80000419
Cyrillic (DOS) 0x8000041b
Thai (Windows, DOS) 0x8000041d
Japanese (Windows, DOS) 0×8
Simplified Chinese (Windows, DOS) 0×80000421
Korean (Windows, DOS) 0×80000422
Traditional Chinese (Windows, DOS) 0×80000423
Western (Windows Latin 1) 0xc
Central European (Windows Latin 2) 0xf
Cyrillic (Windows) 0xb
Greek (Windows) 0xd
Turkish (Windows Latin 5) 0xe
Hebrew (Windows) 0×80000505
Arabic (Windows) 0×80000506
Baltic Rim (Windows) 0×80000507
Vietnamese (Windows) 0×80000508
Western (ASCII) 0×1
Japanese (Shift JIS X0213) 0×80000628
Chinese (GBK) 0×80000631
Chinese (GB 18030) 0×80000632
Japanese (ISO 2022-JP) 0×15
Korean (ISO 2022-KR) 0×80000840
Japanese (EUC) 0×3
Simplified Chinese (EUC) 0×80000930
Traditional Chinese (EUC) 0×80000931
Korean (EUC) 0×80000940
Japanese (Shift JIS) 0x80000a01
Cyrillic (KOI8-R) 0x80000a02
Traditional Chinese (Big 5) 0x80000a03
Western (Mac Mail) 0x80000a04
Traditional Chinese (Big 5 HKSCS) 0x80000a06
Western (NextStep) 0×2
Non-lossy ASCII 0×7
Western (EBCDIC US) 0x80000c02

Ref: NSString의 인코딩

Tagged with:
Aug 30

iOS4에서 백그라운드로 음악을 플레이하거나 스트리밍을 할 때, 아래 그림과 같이 Playback control의 Prev, Play, Next 버튼이 클릭될 때, 이벤트를 받는 방법이다.

-_-;; Stack Overflow에 질문을 했다가 혼 자 답변했다. -_-;
답은 UIApplication의 beginReceivingRemoteControlEvents를 이용하는 것이다.
아래를 viewDidAppear: 정도에 넣어 준다.
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];

해당 View Controller에 아래를 구현하고 YES를 return한다. (Defaul는 NO이다.)

- (BOOL)canBecomeFirstResponder {
 return YES;
}

그리고 나면 Control에 있는 버튼이 클릭 될 때 마다 아래 method가 호출된다.

- (void)remoteControlReceivedWithEvent:(UIEvent *)event {

 if( event.type == UIEventTypeRemoteControl ) {
 NSLog(@"sub type: %d", event.subtype);
 }
}

event.subtype은 아래와 같으니 원하는 것이 다 있을 것이다.

typedef enum {
 // available in iPhone OS 3.0
 UIEventSubtypeNone                              = 0,

 // for UIEventTypeMotion, available in iPhone OS 3.0
 UIEventSubtypeMotionShake                       = 1,

 // for UIEventTypeRemoteControl, available in iPhone OS 4.0
 UIEventSubtypeRemoteControlPlay                 = 100,
 UIEventSubtypeRemoteControlPause                = 101,
 UIEventSubtypeRemoteControlStop                 = 102,
 UIEventSubtypeRemoteControlTogglePlayPause      = 103,
 UIEventSubtypeRemoteControlNextTrack            = 104,
 UIEventSubtypeRemoteControlPreviousTrack        = 105,
 UIEventSubtypeRemoteControlBeginSeekingBackward = 106,
 UIEventSubtypeRemoteControlEndSeekingBackward   = 107,
 UIEventSubtypeRemoteControlBeginSeekingForward  = 108,
 UIEventSubtypeRemoteControlEndSeekingForward    = 109,
} UIEventSubtype;

Ref

1. How can I know users click fast forward and fast rewind buttons on the playback controls in iPhone

2. How do I catch the MPMoviePlayer next button click event while in fullscreen mode on the iPad?

Tagged with:
Aug 27

예전에 twitter한 적도 있지만 포스팅도 한 번 합니다.

Ref: 39 Open Source iPhone App Store Apps – Updated With 2 More Apps!

1. ABC 123Sequence memorization game. Utilizes Cocos2D. (itunes link) (source code)

*2. ArtificeStrategy game where you try to get to the other side by moving boxes out of the way. Utilizes Cocos2D. (itunes link) (source code)

3. ColloquyConversion of the most popular Mac IRC client to the iPhone. (itunes link) (source code)

*4. Countitout - A generic counting app. (itunes link) (source code)

5. Diceshaker - Dice rolling simulator designed for role-playing game enthusiasts. (itunes link) (source code)

6. Doom Classic - Classic 3D first person shooter. (itunes link) (source code) (build instructions)

*7. Ecological Footprint Calculate, display, and record your ecological footprint. (itunes link) (source code)

8. Fosdem - Calendar app for the Fosdem open source conference. (itunes link) (source code)

9. FreshbooksApp that enables usage of Freshbooks web invoicing software from your iPhone. (itunes link) (source code)

10. GorillasClassic Worms/iShoot turn based shooter type game converted to iPhone from basic. Utilizes Cocos2D. (itunes link) (source code).

11. Go Go LottoOpen source lotto ticket generator. (itunes link) (source code)

12. iStrobeTurns the iPhone 4 flash into a highly configurable strobe light. (itunes link) (source code)

13. Last .fm  (itunes link) (source code)

14. Mobilesynth - A monophonic synthesizer designed for live performance. (itunes link) (source code)

15. MoleculesAllows you to view 3D models of molecules and manipulate them through touch. (itunes link) (source code)

16. MoverAllows you to transfer stuff from one iPhone to another by “flicking” it to the other device. (itunes link) (source code)

17. Natsulion - A basic twitter client converted from mac. (itunes link) (source code)

18. NowPlayingAllows you to check local theater listings, and check rotten tomato ratings. (itunes link) (source code)

19. PacklogBackpack journal client. (itunes link) (source code)

20. PlainNoteSimple Open Source Notepad. (itunes link) (source code)

21. PocketFlixFind movies, and manage your Netflix information. (itunes link) (source code)

22. NevoChessA Xiangqi game. (itunes link) (source code)

23. reMailE-mail client featuring ultra-fast search. Removed from app store, but source made available. (source code)

24. RobotFindsKittenPort of a very silly “classic” ASCII game. (itunes link) (source code)

25. Sci-15 HPCalcCalculator app based on classic scientific HP-Calculator. (itunes link) (source code)

26. SpaceBubbleSpace game featuring core graphics, and accelerometer usage. (itunes link) (source code)

27. Star3MapAugmented reality star and planet charting application. (itunes link) (source code)

28. Task CoachPersonal to-do list and task manager. (itunes link) (source code)

29. TubestatusLondon train schedule tracker. (itunes link) (source code)

30. TweejumpPlatform jumping game inspired by Icy Tower. Utilizes Cocos2D. (itunes link) (source code)

31. TweeteeEnhanced version of the Natsulion Twitter Client. (itunes link) (source code)

32. TweeteroBasic twitter client with image uploading. (itunes link) (source code)

33. TwitterfonSuper-fast intuitive twitter client. (itunes link) (source code)

34. ViralFireUnique game where you are a dodging blood cell. (itunes link) (source code)

35. WikihowA reader app for the popular how to wiki site. (itunes link) (source code)

36. Wolfenstein 3D Classic Platinum – If you haven’t heard of Wolfenstein post below so we can say a prayer for you. (itunes link) (source code)

37. WordPressClient for managing WordPress blogs. Also has an iPad version. (itunes link) (source code)

38. YourRightsPocket database containing a summary of your legal rights. (itunes link) (source code)

39. ZBarA barcode reader. (itunes link) (source code)

Tagged with:
Aug 23

http://blogs.techrepublic.com.com/howdoi/?p=120

Tagged with:
preload preload preload