Ver código fonte

Common
rautil 增加随机数函数。

Ray Zhang 7 anos atrás
pai
commit
4bc56383cf

+ 1 - 1
RedAnt ERP Mobile/common/RAUtils.h

@@ -53,7 +53,7 @@
 +(NSString* )current_date;
 +(NSString*) current_date_forfile;
 +(NSMutableArray*)dictionary2array:(NSDictionary*)json count_fields:(NSString*) count_fields item_mark:(NSString*) item_mark items_mark:(NSString* )items_mark;
-
++(int)getRandomNumber:(int)from to:(int)to;
 
 //+(void) add_recent_model:(NSDictionary*) model;
 + (long long) freeDiskSpaceInMegaBytes;

+ 10 - 1
RedAnt ERP Mobile/common/RAUtils.m

@@ -23,7 +23,16 @@
 
 @implementation RAUtils
 
-
++(int)getRandomNumber:(int)from to:(int)to
+{
+    return (int)(from + (arc4random() % (to-from + 1)));
+}
+//+(float)randomf
+//{
+//
+//    int irandom = [self getRandomNumber:0 to:5];
+//    return irandom / 100.0;
+//}
 +(NSString*) getdbzip
 {