小编pab*_*ros的帖子

获取插件com.getdropbox.dropbox.garcon在打开NSOpenPanel时中断

当我打开NSOpenPanel然后我的应用程序崩溃时,我在控制台上收到此消息:

plugin com.getdropbox.dropbox.garcon interrupted
plugin com.getdropbox.dropbox.garcon interrupted
Unable to setup extension context - error: Couldn't communicate with a helper application
Run Code Online (Sandbox Code Playgroud)

在调试器中,我在Thread 6上收到警告说:

Queue: com.apple.NSXPCConnection.user.com.getdropbox.dropbox.garcon.apple-extension-service(serial)
    0_dispatch_barrier_async_f
12 start_wqthread
Enqueued from com.apple.NSXPCConnection.user.com.getdropbox.dropbox.garcon.apple-extension-service (Thread 6)
0_dispatch_barrier_async_f
Run Code Online (Sandbox Code Playgroud)

我尝试用[openPanel runModal]和打开我的NSOpenPannel[openPanel beginSheetModalForWindow:...

我只是用NSOpenPanel来打开一个txt文件

我该怎么做才能停止获取此消息并且应用程序停止崩溃?

该应用程序没有沙盒和代码签名.我只是在Debug-build中尝试,因为我没有Apple开发者帐户.Mac OS X版本为10.10,Dropbox版本为3.0.3

objective-c dropbox nsopenpanel nsxpcconnection

4
推荐指数
1
解决办法
4869
查看次数

如何使用 Swift 2.0 和反射获取属性名称及其值?

鉴于此模型:

public class RSS2Feed {

    public var channel: RSS2FeedChannel?

    public init() {}
}

public class RSS2FeedChannel {   

    public var title: String?
    public var description: String?

    public init() {}

}
Run Code Online (Sandbox Code Playgroud)

我需要做什么才能获得属性名称和值 RSS2FeedChannel实例?

这是我正在尝试的:

let feed = RSS2Feed()
feed.channel = RSS2FeedChannel()
feed.channel?.title = "The Channel Title"

let mirror = Mirror(reflecting: feed.channel)
mirror.children.first // ({Some "Some"}, {{Some "The Channel Title...

for (index, value) in mirror.children.enumerate() {
    index // 0
    value.label // "Some"
    value.value // RSS2FeedChannel
}
Run Code Online (Sandbox Code Playgroud)

最终,我正在尝试创建一个 Dictionary使用反射与实例匹配的对象,但到目前为止我无法获取实例的属性名称和值。

文档说:

可选标签可以在适当的时候使用,例如表示存储属性的名称或活动枚举案例的名称,并将用于在将字符串传递给后代方法时进行查找。

然而我只得到一个“Some”字符串。 …

reflection swift2

4
推荐指数
1
解决办法
4285
查看次数

Lumen 从文件中读取 JSON

我正在使用Lumen Framework并且正在尝试从json文件中为我的数据库设置种子。我正在做这样的事情:

public function run()
{
    $json = json_decode(file_get_contents('database/seed/file.json'), true);
    ...
}
Run Code Online (Sandbox Code Playgroud)

但是当我执行种子命令时php artisan db:seed,我收到此错误:

[错误异常]

file_get_contents(database/seed/file.json):无法打开流:没有这样的文件或目录

我试图这样做:https : //stackoverflow.com/a/34201616/3701102,我得到了这个:

[Symfony\Component\Debug\Exception\FatalThrowableError]

调用未定义的函数 public_path()

任何想法我做错了什么?

谢谢

php laravel lumen

4
推荐指数
1
解决办法
3796
查看次数

Laravel 双重验证正则表达式不起作用

我正在尝试用两位小数验证双精度数,但我无法实现。这是我尝试过的正则表达式和错误,我得到了:

第一次尝试:

$validation = ['price' => 'regex:[0-9]+(\.[0-9][0-9]?)?'];
Run Code Online (Sandbox Code Playgroud)

错误:

preg_match(): 未知修饰符“+”

第二次尝试:

$validation = ['price' => 'regex:[0-9]+(\.[0-9][0-9]?)?'];
Run Code Online (Sandbox Code Playgroud)

错误:

preg_match():分隔符不能是字母数字或反斜杠

第三次尝试:

$validation = ['price' => 'regex:\d+(\.\d{2})?|\.\d{2}'];
Run Code Online (Sandbox Code Playgroud)

错误:

preg_match():分隔符不能是字母数字或反斜杠

我从这个问题中得到了所有的正则表达式:Simple regular expression for a decimal with precision of 2

我究竟做错了什么?或者还有其他方法可以验证带有两位小数的双精度数Laravel吗?

php regex laravel

4
推荐指数
1
解决办法
6479
查看次数

func tableView(_ tableView:UITableView,canEditRowAt indexPath:IndexPath)几乎匹配可选要求

UIViewController喜欢这样的:

class ViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.tableView.dataSource = self
        self.tableView.delegate = self
    }
}

extension ViewController: UITableViewDataSource {
     // datasource methods...
}       

extension ViewController: UITableViewDelegate {
    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
    }
}
Run Code Online (Sandbox Code Playgroud)

但我得到这个警告:

实例方法'tableView(:canEditRowAt :)'几乎匹配协议'UITableViewDelegate'的可选要求'tableView(:canFocusRowAt :)'

我不能删除那个警告.

我该如何删除该警告?

我必须为我工作的公司提交Xcode项目而没有任何警告,我无法找到如何抑制警告.

xcode uitableview ios swift

4
推荐指数
1
解决办法
769
查看次数

无法在tmp目录中保存文件

我有这个功能来保存tmp文件夹中的图像

private func saveImageToTempFolder(image: UIImage, withName name: String) {

    if let data = UIImageJPEGRepresentation(image, 1) {
        let tempDirectoryURL = NSURL.fileURLWithPath(NSTemporaryDirectory(), isDirectory: true)
        let targetURL = tempDirectoryURL.URLByAppendingPathComponent("\(name).jpg").absoluteString
        print("target: \(targetURL)")
        data.writeToFile(targetURL, atomically: true)
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,当我打开我的应用程序的临时文件夹时,它是空的.将图像保存在临时文件夹中我做错了什么?

ios swift

3
推荐指数
1
解决办法
2410
查看次数

如何从Swift 3中的数据中读取属性列表

我正在尝试property listDataSwift 3中读取一个,但我无法实现.

我尝试过这样的事情:

let datasourceDictionary = try! PropertyListSerialization.propertyList(from: data!, options: [PropertyListSerialization.ReadOptions], format: nil) as! Dictionary
Run Code Online (Sandbox Code Playgroud)

我得到了这个错误:

无法将"PropertyListSerialization.ReadOptions.Type"类型的值(也称为"PropertyListSerialization.MutabilityOptions.Type")转换为预期的元素类型"PropertyListSerialization.MutabilityOptions"

然后我尝试了类似这样的东西,就像我以前在Swift 1.2上做的那样:

let datasourceDictionary = try! PropertyListSerialization.propertyList(from: data!, options: [PropertyListSerialization.MutabilityOptions.immutable], format: nil) as! Dictionary
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

'immutable'不可用:使用[]构造一个空选项集

然后我尝试了这个:

let datasourceDictionary = try! PropertyListSerialization.propertyList(from: data!, options: [], format: nil) as! Dictionary
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

'[Any]'不能转换为'PropertyListSerialization.ReadOptions'(又名'PropertyListSerialization.MutabilityOptions')

如何property list从"Swift 3中的数据"中读取文件或者执行此操作的方法是什么?

nsdata swift swift3

3
推荐指数
2
解决办法
5476
查看次数

命令"make:seeder"未在Lumen 5.2中定义

我正在开发我的第一个Lumen项目,我尝试seed class为我的数据库创建一个.

我正在尝试运行下一个命令:

php artisan make:seeder UsersTableSeeder
Run Code Online (Sandbox Code Playgroud)

但我总是得到这个错误:

[Symfony的\元器件\控制台\异常\ CommandNotFoundException]

命令"make:seeder"未定义.

你的意思是其中之一吗?

  db:seed

  make:migration
Run Code Online (Sandbox Code Playgroud)

我正在寻找如何解决这个问题,但我找不到任何东西.有什么想法我需要做什么?

我正在使用 lumen-framework 5.2.*

php laravel artisan lumen lumen-5.2

2
推荐指数
1
解决办法
2037
查看次数

UIBarButtonItem为popoverPresentationController提供了错误的框架

我有一个工具栏,UIBarButtomItem左边有一个标签Admin

在此输入图像描述

我需要在点击它时显示一个弹出窗口,但它出现在错误的位置,它出现在屏幕的左上角:

在此输入图像描述

这是打开popover的功能:

// this IBAction is assigned only to the Admin bar button item
@IBAction func openAdmin(sender: UIBarButtonItem) {
    let alertController = UIAlertController(title: nil, message: "Elige una opción", preferredStyle: .ActionSheet)

    // action button initializations... ... ...

    let barButtonItemSize = sender.valueForKey("view")

    alertController.popoverPresentationController?.sourceView = self.view
    alertController.popoverPresentationController?.sourceRect = barButtonItemSize!.frame

    presentViewController(alertController, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

当我触摸管理栏按钮时,我也会在控制台上收到此警告:

快照未呈现的视图会导致空快照.确保在屏幕更新后快照或快照之前至少渲染了一次视图

我究竟做错了什么?或者我需要做什么才能在管理员的顶部显示popover?

uibarbuttonitem ios uipopover swift

2
推荐指数
1
解决办法
1248
查看次数

Swift 3 - 如何将 NSMutableArray 对象附加到另一个 NSMutableArray

我想在 Swift 3 上将对象从一个附加NSMutablArray到另一个NSMutableArray,但我无法实现。

这是我首先尝试做的:

mutableArray.addObjects(from: anotherMutableArray)
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

无法转换“NSMutableArray”类型的值?到预期的参数类型 '[Any]'

然后我尝试了这个:

mutableArray.addObjects(from: anotherMutableArray as [Any])
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

无法转换“NSMutableArray”类型的值?强制输入“[Any]”

如何在 Swift 3 上将对象从一个附加NSMutableArray到另一个NSMutableArray

nsmutablearray swift swift3

2
推荐指数
1
解决办法
3916
查看次数