Category Archives: objective-c

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.  

Calculating distance in Objective-C

Returns distance in meters between to coordinates.

  1.  
  1. float calcDistance(float lat1, float lon1, float lat2,float lon2)
  2. {
  3.         float R = 6371; // km
  4.         float dLat = deg2rad((lat2-lat1));
  5.         float dLon = deg2rad((lon2-lon1));
  6.         float a = sin(dLat/2.0) *
  7. sin(dLat/2.0)+cos(deg2rad(lat1))*
  8. cos(deg2rad(lat2))*sin(dLon/2.0)*sin(dLon/2.0);
  9.         float c = 2.0 * atan2(sqrt(a), sqrt(1-a));
  10.         float d = R * c;
  11.  
  12.         return d*1000;
  13. }