我正在使用swift构建一个RSS阅读器,需要实现pull to reload功能.
这是我试图这样做的方式.
class FirstViewController: UIViewController,
UITableViewDelegate, UITableViewDataSource {
@IBOutlet var refresh: UIScreenEdgePanGestureRecognizer
@IBOutlet var newsCollect: UITableView
var activityIndicator:UIActivityIndicatorView? = nil
override func viewDidLoad() {
super.viewDidLoad()
self.newsCollect.scrollEnabled = true
// Do any additional setup after loading the view, typically from a nib.
if nCollect.news.count <= 2{
self.collectNews()
}
else{
self.removeActivityIndicator()
}
view.addGestureRecognizer(refresh)
}
@IBAction func reload(sender: UIScreenEdgePanGestureRecognizer) {
nCollect.news = News[]()
return newsCollect.reloadData()
}
Run Code Online (Sandbox Code Playgroud)
我正进入(状态 :
属性'self.refresh'未在super.init调用中初始化
请帮助我理解手势识别器的行为.一个工作示例代码将是一个很好的帮助.
谢谢.
我正在写一个库,所以不使用UIKit,即使在我的iOS应用程序中,相同的代码也可以工作,但是当我在命令行中执行时却没有.在PlayGround中也似乎有效.
由于某种原因,回调没有被触发,因此print语句没有执行.
internal class func post(request: URLRequest, responseCallback: @escaping (Bool, AnyObject?) -> ()) {
execTask(request: request, taskCallback: { (status, resp) -> Void in
responseCallback(status, resp)
})
}
internal class func clientURLRequest(url: URL, path: String, method: RequestMethod.RawValue, params: Dictionary<String, Any>? = nil) -> URLRequest {
var request = URLRequest(url: url)
request.httpMethod = method
do {
let jsonData = try JSONSerialization.data(withJSONObject: (params! as [String : Any]), options: .prettyPrinted)
request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.httpBody = jsonData
} catch let error as NSError { …
Run Code Online (Sandbox Code Playgroud) 目前,在ES 5.6上,我们使用groovy内联脚本来获取给定文档中给定术语的tf,如 -
GET document/_search
{
"size": 114,
"query": {"terms": {
"doc_id": [1840, 2160]
}},
"script_fields": {
"tf": {
"script": {
"lang": "groovy",
"inline": "_index['text'][term_value].tf()",
"params": {
"term_value": "hello"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以它回复我的回应 -
"hits": {
"total": 36,
"max_score": 1,
"hits": [
{
"_index": "document",
"_type": "sample",
"_id": "41707",
"_score": 1,
"fields": {
"tf": [
3
]
}
}]
Run Code Online (Sandbox Code Playgroud)
但是在ES 6.0 groovy
支持下降之后,似乎脚本引擎是唯一的解决方案,而且由于缺乏对Elasticsearch类和内部行为的正确理解,很难弄清楚实现.
基于Scripting Engine文档,我需要实现
private static class MyExpertScriptEngine implements ScriptEngine {
@Override
public String getType() {
return …
Run Code Online (Sandbox Code Playgroud) elasticsearch elasticsearch-plugin elasticsearch-painless elasticsearch-6
我在stackoverflow上发现了很多关于这方面的问题,但没有解决我的问题.经过大量的谷歌搜索仍然我面临AccessDenied异常:
<Error>
<Code>AccessDenied</Code>
</Message><RequestId>ADF9C0DE6C86DF4F</RequestId>
<HostId>JwQLkNB0LuJvh0jwrsJe9wazxLsd+hrZ2qwvjCvmXYd2A/ckCrsotRMHm</HostId>
</Error>
Run Code Online (Sandbox Code Playgroud)
以下是我的用户和组策略文档:
{
"Statement":[
{
"Sid":"AllowListBucketIfSpecificPrefixIsIncludedInRequest",
"Action":"s3:*",
"Effect":"Allow",
"Resource":["arn:aws:s3::: mybucket", "arn:aws:s3:::mybucket/*"],
"Condition":{
"StringLike":{"s3:prefix":["Development/*"]
}
}
},
{
"Sid":"AllowUserToReadWriteObjectDataInDevelopmentFolder",
"Action":"s3:*",
"Effect":"Allow",
"Resource":["arn:aws:s3::: mybucket/Development/*"]
},
{
"Sid": "ExplicitlyDenyAnyRequestsForAllOtherFoldersExceptDevelopment",
"Action": ["s3:ListBucket"],
"Effect": "Deny",
"Resource": ["arn:aws:s3::: mybucket", "arn:aws:s3::: mybucket/*"],
"Condition":{ "StringNotLike": {"s3:prefix":["Development/*"] },
"Null" : {"s3:prefix":false }
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
{
"Statement": [
{
"Sid": "AllowGroupToSeeBucketListAndAlsoAllowGetBucketLocationRequiredForListBucket",
"Action": ["s3:ListAllMyBuckets", "s3:GetBucketLocation"],
"Effect": "Allow",
"Resource": ["arn:aws:s3:::*"]
},
{
"Sid": "AllowRootLevelListingOfCompanyBucket",
"Action": ["s3:ListBucket"],
"Effect": "Allow",
"Resource": ["arn:aws:s3::: mybucket", "arn:aws:s3::: mybucket/*"], …
Run Code Online (Sandbox Code Playgroud) amazon-iam ×1
amazon-s3 ×1
boto ×1
ios ×1
nsurlsession ×1
python ×1
swift ×1
swift3 ×1
xcode ×1