Category Archives: cocoa

iOS touchesEnded for multitouch single finger release

If you need to know which finger actually were lifted from screen when doing a multiple touch tracking, you need to check the phase variable from UITouch to see if it has been actually lifted from screen. If the single touch has ended, it’s phase will be UITouchPhaseEnded

Normally when you lift one finger, the touchesEnded is called with a set of all active touches. I wish it would be a set of only touches that have ended.

Example code:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
{
NSSet *allTouches = [event allTouches];

for (int zz=0;zz<[allTouches count];zz++)
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:zz];

CGPoint touchPos = [touch locationInView:self];

if (touch.phase==UITouchPhaseEnded)
{

How to remove the gloss / glare / white area from iPhone app icon?

To remove the gloss / glare / white area from iPhone app icon that iPhone adds automatically – go to the Xcode and open up the App’s Info.plist. On right side you see list like button. Press that and you’ll get new row with selectable property name. From there pick the “Icon already includes gloss..” and check the checkbox.

So in short: it’s a property in the App info.plist.

Working MD5 for Objective-C

  1.  
  2.  
  3. #import <CommonCrypto/CommonDigest.h>
  4.  
  5.  
  6. NSString * md5( NSString *str )
  7. {
  8.  
  9. const char *cStr = [str UTF8String];
  10.  
  11. unsigned char result[CC_MD5_DIGEST_LENGTH];
  12.  
  13. CC_MD5( cStr, strlen(cStr), result );
  14.  
  15. return [NSString stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  16. result[0], result[1],
  17. result[2], result[3],
  18. result[4], result[5],
  19. result[6], result[7],
  20. result[8], result[9],
  21. result[10], result[11],
  22. result[12], result[13],
  23. result[14], result[15]];
  24.  
  25. }
  26.  
  27.