小编Cli*_*rum的帖子

使用 Promise 通过 Parse Cloud 代码进行多个查询

我有两个问题:

  1. 下面的示例是在单个 Cloud Code 函数中执行多个 Parse 查询的正确方法吗?
  2. 下面的示例是否将通过一个HTTP 请求(当我调用)提供我正在查询的所有数据logbookEntries,然后将其计为我帐户上的两个Parse 请求,因为它是两个 Parse 查询?

这是代码:

Parse.Cloud.define("logbookEntries", function(request, response) {

  //::: Query 1 :::
  var firstQuery = new Parse.Query("Logbook");
  var returnData = []; 

  firstQuery.find().then(function(firstResults) {
    returnData[0] = firstResults; 

  }).then(function(result) {  

    //::: Query 2 :::
    var secondQuery = new Parse.Query("Logbook"); 
    secondQuery.find().then(function(secondResults))
    returnData[1] = secondResults; 

  }).then(function(result) {
    response.success(returnData);

  }, function(error) {
    response.error(error);

  });
});
Run Code Online (Sandbox Code Playgroud)

提前致谢。

backbone.js parse-platform parse-cloud-code

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

使用IBInspectable在选定状态下的UIButton边框颜色

我正在使用像这样的Swift扩展@IBInspectable来设置边框颜色UIButton:

extension UIButton {
  @IBInspectable var borderWidth: CGFloat {
    get {
      return layer.borderWidth
    }
    set {
      layer.borderWidth = newValue
      layer.masksToBounds = newValue > 0
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

...但我也想拥有按钮状态的selectedBorderColor属性.Selected.这可能是这样的扩展吗?我是否必须以UIButton某种方式继承并检查按钮状态?

extension UIButton {
  @IBInspectable var borderWidth: CGFloat {
    get {
      return layer.borderWidth
    }
    set {
      layer.borderWidth = newValue
      layer.masksToBounds = newValue > 0
    }
  }
  //This is what I want to do...
  @IBInspectable var selectedBorderWidth: CGFloat {
    get {
      return layer.borderWidth
    } …
Run Code Online (Sandbox Code Playgroud)

uibutton ios swift swift-extensions ibinspectable

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

核心数据与iOS上的FMDB相结合

我喜欢Core Data,并且很享受简单的数据库事务.但是我还需要做几个复杂的查询,我担心Core Data不会让这些查询变得容易.

以下是我需要做的各种查询的几个示例(这些是在MySQL中,但如果需要,我会在以后针对SQLite进行调整):

http://d.pr/n/h0mD

http://d.pr/n/ZVVx

所以这是我的问题:

  1. Core Data及其NSPredicates是否允许我做所有这些事情?(日期限制,if/else条件,加入,分组等)
  2. 如果这是不可能的(或者可以通过合理的努力来实现),我可以使用类似FMDB Core Data的东西吗?(是的,我知道我必须要小心)

我期待着您的见解.谢谢!

core-data fmdb ios

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

Objective-C:将十六进制字符串转换为整数以比较哪个更大

我的目标是比较两个十六进制字符串并确定哪个数字更高.我假设我需要将这些十六进制字符串转换为整数,以便能够在数学上对它们进行比较,但转换unsigned为无效.这是我尝试过的:

NSString *firstHex = @"35c1f029684fe";
NSString *secondHex = @"35c1f029684ff";

unsigned first = 0;
unsigned second = 0;

NSScanner *firstScanner = [NSScanner scannerWithString:firstHex];
NSScanner *secondScanner = [NSScanner scannerWithString:secondHex];

[firstScanner scanHexInt:&first];
[secondScanner scanHexInt:&second];

NSLog(@"First: %d",first);
NSLog(@"Second: %d",second);
Run Code Online (Sandbox Code Playgroud)

但是日志输出给了我:

First: -1
Second: -1
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚我做错了什么.我NSScanner在这里使用得当吗?提前致谢.

hex objective-c nsscanner

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

故事板中导航栏标题视图中的 UIButton 和标签

我在导航标题栏中添加了几个标签和图像。这一切都很好。但我想用 a 覆盖所有内容UIButton,但我无法UIButton注册任何水龙头。

这是我的视图层次结构:

导航栏视图

所有内容均启用用户交互,并且我已IBAction连接到按钮,如下所示:

@IBAction func tapProjectEdit(_ sender: UIButton) {
  print("This never fires. :(")
}
Run Code Online (Sandbox Code Playgroud)

UIButton导航栏中不允许有 吗?还有其他方法可以解决这个问题吗?

uinavigationbar uibutton uinavigationitem ios uistoryboard

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

对 Superview 边缘的编程自动布局约束

我在 Xcode 的故事板编辑器中做了很多自动布局,但我很少在代码中做任何事情。在一个特定的实例中,我需要创建与这些约束等效的编程:

在此处输入图片说明

这些约束被添加到textView超级视图是另一个名为commentBox. 到目前为止我已经尝试过这个,但是代码感觉是多余的,并导致冲突约束的自动布局错误:

//Trailing
textView.addConstraint(NSLayoutConstraint(item: textView, attribute: .trailing, relatedBy: .equal, toItem: cell.commentBox, attribute: .trailing, multiplier: 1, constant: 15))
//Leading
textView.addConstraint(NSLayoutConstraint(item: textView, attribute: .leading, relatedBy: .equal, toItem: cell.commentBox, attribute: .leading, multiplier: 1, constant: 15))
//Bottom
textView.addConstraint(NSLayoutConstraint(item: textView, attribute: .bottom, relatedBy: .equal, toItem: cell.commentBox, attribute: .bottom, multiplier: 1, constant: 10))
//Top
textView.addConstraint(NSLayoutConstraint(item: textView, attribute: .top, relatedBy: .equal, toItem: cell.commentBox, attribute: .top, multiplier: 1, constant: 10))
Run Code Online (Sandbox Code Playgroud)

知道我做错了什么吗?谢谢!

autolayout nslayoutconstraint swift

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

Vue JS:使用按钮打开菜单组件,通过单击菜单外部关闭

Vue JS 2.6.10

我读过很多关于如何创建自定义指令的帖子,以便您可以检测到弹出菜单外部的单击,以便可以将其关闭。我无法完全让它工作,因为我有一个打开菜单的按钮,单击它会触发“关闭”行为。

这是我的主视图Logbook.vue,其中包含打开菜单的按钮: 在此输入图像描述

// --- Logbook.vue ---
<script>
export default {
  name: 'Logbook',
  components:{
    Years
  },
  methods:{
    clickYears: function(){
      this.$refs.Years.show = true
    }
  }
}
</script>
<template>
  <div id="current-year">
    <a href="#year" ref="yearButton" v-on:click.prevent="clickYears">{{ currentYear }}</a>
    <Years ref="Years" v-on:selectYear="yearSelected" />
  </div>
</template>
Run Code Online (Sandbox Code Playgroud)

Years.vue以下是单击按钮时打开的 菜单组件:在此输入图像描述

//--- Years.vue ---
<script>
import Vue from 'vue'

//Custom directive to handle clicks outside of this component
Vue.directive('click-outside', {
  bind: function (el, binding, vnode) {
    window.event = function (event) {
      if (!(el …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vue-component vuejs2 custom-directive

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

在 SvelteKit 项目中全局包含类型

SvelteKit v1.0.0-next.354

在我的所有商店、组件和 API 中,我必须手动设置import类型才能使用它们,以防止 VS Code 中出现 TypeScript 错误:

import type { MyType } from '$lib/types`
Run Code Online (Sandbox Code Playgroud)

我尝试将我的类放入其中app.d.ts,但这没有用。

declare namespace App{
  export class Aircraft{
    ...
  }
}
Run Code Online (Sandbox Code Playgroud)

对于一个包含数十个文件的非常大的项目来说,这变得相当麻烦。

有没有某种方法可以将我的所有类型全局包含在一个位置,以便它们可以在我的项目中的任何文件中使用?我对 TypeScript 很陌生,不确定它是如何工作的。

typescript tsconfig svelte sveltekit

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