swift-xattr

码农软件 · 软件分类 · 常用工具包 · 2019-08-18 10:13:44

软件介绍

swift-xattr 是 iOS/OSX Swift 语言的可扩展文件属性封装器,可处理下列函数:setxattr, getxattr, listxattr, removexattr。

使用示例:

import Foundation

var errorOrNames = attributesNamesAtPath("/file.txt")

if let names = errorOrNames.names {

  names.map { println($0) }
}
else {

  println(errorOrNames.error)
}

> com.apple.FinderInfo
> com.apple.metadata:_kMDItemUserTags

setAttributeWithName("custom", data: "abc".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!, atPath: "/file.txt")

errorOrNames = attributesNamesAtPath("/file.txt")

if let names = errorOrNames.names {

  names.map { println($0) }
}
else {

  println(errorOrNames.error)
}

> com.apple.FinderInfo
> com.apple.metadata:_kMDItemUserTags
> custom

var errorOrData = dataForAttributeNamed("custom", atPath: "/file.txt")

if let data = errorOrData.data {

  println(NSString(data: data, encoding: NSUTF8StringEncoding))
}
else {

  println(errorOrData.error)
}

> abc

removeAttributeNamed("custom", atPath: "/file.txt")

errorOrData = dataForAttributeNamed("custom", atPath: "/file.txt")

if let data = errorOrData.data {

  println(NSString(data: data, encoding: NSUTF8StringEncoding))
}
else {

  println(errorOrData.error)
}

> Attribute not found

测试系统:Xcode 6.3, iOS 8.1.1, OS X 10.10

本文地址:https://codercto.com/soft/d/12621.html

The NSHipster Fake Book (Objective-C)

The NSHipster Fake Book (Objective-C)

Mattt Thompson / NSHipster Portland, Oregon / 2014 / USD 19.00

Fake Books are an indispensable tool for jazz musicians. They contain the melody, rhythm, and chord changes for hundreds of standards, allowing a player to jump into any session cold, and "fake it" th......一起来看看 《The NSHipster Fake Book (Objective-C)》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具