错误1:当我尝试stringValue从元数据显示以上错误时Swift3:
let myMetadata: AVMetadataMachineReadableCodeObject = metadataObjects[0] as! AVMetadataMachineReadableCodeObject
// take out the system and check-digits
let myBarcode = myMetadata.stringValue[1...11] //error
Run Code Online (Sandbox Code Playgroud)
错误2:
在String的扩展中,我将这些写入get right(x)和left(x)function来获取子字符串:
extension String {
// length of string
var length: Int {
return self.characters.count
}
// right(x) and left(x) function to get substring
func right(_ i: Int) -> String?
{
return self[self.length-i ... self.length-1 ] //error
}
func left(_ i: Int) -> String?
{
return self[0 ... i-1] //error
} …Run Code Online (Sandbox Code Playgroud) 创建了新项目并添加了ActionExtension它工作并在Action Activities中显示但是当我为现有应用程序(包含swift和Objective-c文件的旧应用程序)创建时,Action Extension不显示在Device中我需要在Action Extension中显示我的应用程序UiactivityController但我无法在Device参考图像中显示For Every Application

***查询:在模拟器(照片应用程序)中显示它并且它在模拟器中的其他应用程序中不显示但是当我在设备中运行时它不会在照片应用程序和其他应用程序中显示
override func viewDidLoad() {
super.viewDidLoad()
// Get the item[s] we're handling from the extension context.
// For example, look for an image and place it into an image view.
// Replace this with something appropriate for the type[s] your extension supports.
var imageFound = false
for item: AnyObject in self.extensionContext!.inputItems {
let inputItem = item as! NSExtensionItem
for provider: AnyObject in inputItem.attachments! {
let itemProvider = provider as! NSItemProvider
if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage as String) …Run Code Online (Sandbox Code Playgroud) 似乎是在Swift3中更改了许多语法,我无法找到这个currencyStyle的解决方案我提到的文档没有替换这个.如果有人遇到这个错误,请你点击下面的答案?我在下面提到的链接可以使用
func getCurrencyFormat(amount: Double) -> NSString
{
let amountFormatter = NumberFormatter()
amountFormatter.numberStyle = NumberFormatter.currencyStyle -- ///ERROR
amountFormatter.locale = NSLocale.system
return amountFormatter.string(from: amount as NSNumber)! as NSString
}
Run Code Online (Sandbox Code Playgroud)
引用链接仅适用于swift2 在Swift中使用NSNumberFormatter进行货币争夺