Permalink
Browse files

Added UUID generator method to CPString.

  • Loading branch information...
1 parent 40def35 commit 1758e18bd248cb07814bd4aabfbc0caa30fbffec nciagra committed with Ross Boucher Jan 31, 2009
Showing with 18 additions and 0 deletions.
  1. +18 −0 Foundation/CPString.j
View
@@ -662,4 +662,22 @@ var CPStringHashes = new objj_dictionary();
@end
+
+@implementation CPString (UUID)
+
+/*!
+ Returns a randomly generated Universally Unique Identifier.
+*/
++ (CPString)UUID
+{
+ var g = @"";
+
+ for(var i = 0; i < 32; i++)
+ g += Math.floor(Math.random() * 0xF).toString(0xF);
+
+ return g;
+}
+
+@end
+
String.prototype.isa = CPString;

0 comments on commit 1758e18

Please sign in to comment.