I read that NSTemporaryDirectory()
returns a string for a temporary directory, but may also return nil.
Is this the case in iOS? Has anyone experience with NSTemporaryDirectory()
returning nil? When does it happen?
If i have to be prepared that NSTemporaryDirectory()
may return nil, it does not make sense for me to use it altogether. If i have to provide a fallback m开发者_JS百科echanism i can use this mechanism in the first place.
So what is a simple and safe way to create a temporary directory?
Being realistic, any situation that would lead NSTemporaryDirectory to return nil, would most likely mean that you wouldn't be able to save anything yourself anyway.
i.e.: It's likely to mean that the device is full, or that some form of corruption has occurred.
As such, I suspect that you should stick to using NSTemporaryDirectory (why re-invent the wheel after all) and treat it returning nil as effectively meaning you can't write to local storage.
精彩评论