我有一个数组:
[h,e,l,l,o]
Run Code Online (Sandbox Code Playgroud)
我想替换索引上的值,例如我想更改索引2处的第一个l.我知道索引所以这不是问题,唯一的问题是替换该值.
我怎样才能做到这一点?
当我使用指南针手表时,它看不到el capitan的任何变化.对小牛来说,它可以工作并检测到一切.
有人知道什么是修复?
我已经使这个功能得到了每一天的所有步骤,但是我想将这个函数从swift 2.x转换为swift 3.但是我被困在两个不同的点上.
let anchorDate = calendar.dateComponents(anchorComponents)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:无法使用列表类型的参数(Datecomponents)调用dateCompontents
在这一点上:
let stepsQuery = HKStatisticsCollectionQuery(quantityType: HKQuantityType, quantitySamplePredicate: nil, options: .CumulativeSum, anchorDate: anchorComponents!, intervalComponents: interval)
Run Code Online (Sandbox Code Playgroud)
错误:无法将HKQuantityType.Type类型的值转换为预期的参数类型HKQuantityType.
完整的功能:
func getDailySteps(){
let calendar = NSCalendar.current
let interval = NSDateComponents()
interval.day = 1
var anchorComponents = calendar.dateComponents([.day , .month , .year], from: NSDate() as Date)
anchorComponents.hour = 0
let anchorDate = calendar.dateComponents(anchorComponents)
// Define 1-day intervals starting from 0:00
let stepsQuery = HKStatisticsCollectionQuery(quantityType: HKQuantityType, quantitySamplePredicate: nil, options: .CumulativeSum, anchorDate: anchorComponents!, intervalComponents: interval)
// Set …Run Code Online (Sandbox Code Playgroud) 我有一个UIScrollView里面有一些标签.我可以使用按钮将滚动视图移动到另一个"页面".但是当我把它推得太快时,偏移是不对的.
我将滚动视图移动到下一页的代码:
@IBAction func moveToRight(_ sender: Any) {
let size = Int(scrView.contentOffset.x) + Int(scrView.frame.size.width);
scrView.setContentOffset(CGPoint(x: size, y: 0), animated: true)
}
Run Code Online (Sandbox Code Playgroud)
当我推得太快时,偏移是不对的.看起来当前动画停止并将从当前(未完成)位置执行下一个动画.
有人有解决方案吗?
我想比较两个数组是否相等,这是我的代码:
var letteronloc = [String]();
letteronloc.append("test")
let characters = Array("test")
if(letteronloc == characters) {
}
Run Code Online (Sandbox Code Playgroud)
但我有一个错误:找不到接受提供的参数的==的重载
我认为这是因为数组不相等,因为第二个数组不是字符串数组.但我该如何解决这个问题呢?
我想SKProduct在显示实际页面之前加载。但是我在创建它时遇到了一些困难。
我当时想制作另一个加载产品的类,如下所示:
class GetIapInfo: NSObject, SKProductsRequestDelegate {
var list = [SKProduct]()
var p = SKProduct()
let audio = "com.xxx";
let video = "com.xxx"
let complete = "com.xxx"
override init() {
super.init()
if SKPaymentQueue.canMakePayments() {
print("starting IAPS")
let productIdentifiers = Set([audio, vídeo, complete])
let request = SKProductsRequest(productIdentifiers: productIdentifiers)
request.delegate = self
request.start()
} else {
print("please enable IAPS")
}
}
internal func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
print("product request")
let myProduct = response.products
for product in myProduct …Run Code Online (Sandbox Code Playgroud) 我正在开发一个带有 express 和把手的 NodeJs 应用程序。我想要的是我可以重用一些部分,如页眉和页脚元素。
所以我想,我选择了'base' html。并通过 Handlebars 在其中拍摄所需的 html 元素。
我的 index.js 中有这个:
const functions = require('firebase-functions');
const express = require('express');
const engines = require('consolidate');
const app = express();
app.engine('hbs', engines.handlebars);
app.set('views', './views');
app.set('view engine', 'hbs');
app.get('/activiteiten', (request, response) => {
// var test = require('./views/dayCard.hbs');
// var data = {display_name: "hi"};
// var theCompiledHtml = test(data);
response.render('index', {
menu_item: "Mijn Dashboard",
menu_sub: "Activiteiten"
//content: theCompiledHtml
});
});
exports.app = functions.https.onRequest(app);
Run Code Online (Sandbox Code Playgroud)
这像预期的那样工作。但我想在其中附加一些数据。所以我在模板中创建了内容标签。除此之外,我已将 html 添加到 dayCard.hbs。
Daycard.hbs:
<div class="col-xs-12 col-md-6 …Run Code Online (Sandbox Code Playgroud) swift ×5
ios ×2
asynchronous ×1
compass ×1
compass-sass ×1
delegates ×1
javascript ×1
jquery ×1
macos ×1
node.js ×1
ruby ×1
sass ×1
swift3 ×1
uiscrollview ×1
xcode ×1