First, NSFilePosixPermissions
is the name of a constant. Its value may also be the same, but this is not guaranteed. The value of the NSFilePosixPermissions
constant can vary between platform releases, for example, from @"NSFilePosixPermissions"
to @"posixPermisions"
. That would break your code. The correct way is to use the constant as NSFilePosixPermissions
, not @"NSFilePosixPermissions"
.
In addition, the NSFilePosixPermissions link talks about NSFilePosixPermisions
:
The corresponding value is an NSNumber
object. Use the shortValue
method to get an integer value for permissions.
The correct way to set POSIX permissions is:
// chmod permissions 777 // Swift attributes[NSFilePosixPermissions] = 0o777 // Objective-C [attributes setValue:[NSNumber numberWithShort:0777] forKey:NSFilePosixPermissions];
source share