/
NSString+DTPaths.h
86 lines (54 loc) · 2.43 KB
/
NSString+DTPaths.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// NSString+DTPaths.h
// DTFoundation
//
// Created by Oliver Drobnik on 2/15/12.
// Copyright (c) 2012 Cocoanetics. All rights reserved.
//
/**
A collection of useful additions for `NSString` to deal with paths.
*/
@interface NSString (DTPaths)
/**-------------------------------------------------------------------------------------
@name Getting Standard Paths
---------------------------------------------------------------------------------------
*/
/** Determines the path to the Library/Caches folder in the current application's sandbox.
The return value is cached on the first call.
@return The path to the app's Caches folder.
*/
+ (NSString *)cachesPath;
/** Determines the path to the Documents folder in the current application's sandbox.
The return value is cached on the first call.
@return The path to the app's Documents folder.
*/
+ (NSString *)documentsPath;
/**-------------------------------------------------------------------------------------
@name Getting Temporary Paths
---------------------------------------------------------------------------------------
*/
/** Determines the path for temporary files in the current application's sandbox.
The return value is cached on the first call. This value is different in Simulator than on the actual device. In Simulator you get a reference to /tmp wheras on iOS devices it is a special folder inside the application folder.
@return The path to the app's folder for temporary files.
*/
+ (NSString *)temporaryPath;
/** Creates a unique filename that can be used for one temporary file or folder.
The returned string is different on every call. It is created by combining the result from temporaryPath with a unique UUID.
@return The generated temporary path.
*/
+ (NSString *)pathForTemporaryFile;
/**-------------------------------------------------------------------------------------
@name Working with Paths
---------------------------------------------------------------------------------------
*/
/** Appends or Increments a sequence number in brackets
If the receiver already has a number suffix then it is incremented. If not then (1) is added.
@return The incremented path
*/
- (NSString *)pathByIncrementingSequenceNumber;
/** Removes a sequence number in brackets
If the receiver number suffix then it is removed. If not the receiver is returned.
@return The modified path
*/
- (NSString *)pathByDeletingSequenceNumber;
@end