瀏覽代碼

createFileNameFromAsset Add mask date DD MM YY

Marino Faggiana 8 年之前
父節點
當前提交
7be07e2a7e
共有 1 個文件被更改,包括 22 次插入2 次删除
  1. 22 2
      iOSClient/Utility/CCUtility.m

+ 22 - 2
iOSClient/Utility/CCUtility.m

@@ -495,13 +495,33 @@
     NSString *fileNameExt = [[assetFileName pathExtension] lowercaseString];
     
     if (key) {
+        
         fileName = [CCUtility getFileNameMask:key];
-        if ([fileName length] > 0)
+        
+        if ([fileName length] > 0) {
+            
+            [formatter setDateFormat:@"dd"];
+            NSString *day = [formatter stringFromDate:assetDate];
+            [formatter setDateFormat:@"MMM"];
+            NSString *month = [formatter stringFromDate:assetDate];
+            [formatter setDateFormat:@"yyyy"];
+            NSString *year = [formatter stringFromDate:assetDate];
+            
+            // Replace string with date
+
+            fileName = [fileName stringByReplacingOccurrencesOfString:@"DD" withString:day];
+            fileName = [fileName stringByReplacingOccurrencesOfString:@"MM" withString:month];
+            fileName = [fileName stringByReplacingOccurrencesOfString:@"YY" withString:year];
+
             fileName = [NSString stringWithFormat:@"%@-%@.%@", fileName, numberFileName, fileNameExt];
-        else
+            
+        } else {
+            
             fileName = [NSString stringWithFormat:@"%@ %@.%@", fileNameDate, numberFileName, fileNameExt];
+        }
         
     } else {
+        
         fileName = [NSString stringWithFormat:@"%@ %@.%@", fileNameDate, numberFileName, fileNameExt];
     }