小编Smo*_*tor的帖子

Swift中的HomeKit完成块:无法将表达式的类型'Void'转换为'String!'类型

我正在玩HomeKit,我正在尝试添加一个新家.这是我的代码:

func addHome()
{
    homeManager.addHomeWithName("My House", completionHandler:
        { (error: NSError!, home: HMHome!) in
            if error
            {
                NSLog("%@", error)
            }
        })
}
Run Code Online (Sandbox Code Playgroud)

这给出了编译器错误:

Cannot convert the expression's type 'Void' to type 'String!'
Run Code Online (Sandbox Code Playgroud)

我试过指定一个返回类型Void:

...
{ (error: NSError!, home: HMHome!) -> Void in
...
Run Code Online (Sandbox Code Playgroud)

无济于事.有没有人有任何想法如何解决这个问题?传递nil给完成处理程序修复了错误,但当然我想在完成时做一些事情.

closures ios swift homekit

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

如何从列中减去常数

有没有办法从列的所有值中减去最小值?我需要从第一列中的所有其他数字中减去第一列中的第一个数字.

我写了这个脚本,但它没有给出正确的结果:

$ awk '{$1 = $1 - 1280449530}' file 
1280449530 452
1280449531 2434
1280449531 2681
1280449531 2946
1280449531 1626
1280449532 3217
1280449532 4764
1280449532 4501
1280449532 3372
1280449533 4129
1280449533 6937
1280449533 6423
1280449533 4818
1280449534 4850
1280449534 8980
1280449534 8078
1280449534 6788
1280449535 5587
1280449535 10879
1280449535 9920
1280449535 8146
1280449536 6324
1280449536 12860
1280449536 11612
Run Code Online (Sandbox Code Playgroud)

awk subtraction

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

C函数const多维数组参数中的奇怪警告

我对这段代码有一些奇怪的警告:

typedef double mat4[4][4];

void mprod4(mat4 r, const mat4 a, const mat4 b)
{
/* yes, function is empty */
}

int main()
{
    mat4 mr, ma, mb;
    mprod4(mr, ma, mb);
}
Run Code Online (Sandbox Code Playgroud)

gcc 输出如下:

$ gcc -o test test.c
test.c: In function 'main':
test.c:13: warning: passing argument 2 of 'mprod4' from incompatible pointer
type
test.c:4: note: expected 'const double (*)[4]' but argument is of type 'double
(*)[4]'
test.c:13: warning: passing argument 3 of 'mprod4' from incompatible pointer
type
test.c:4:
note: …
Run Code Online (Sandbox Code Playgroud)

c arguments const function multidimensional-array

7
推荐指数
2
解决办法
5086
查看次数

"创建视图"必须是批次中唯一的语句

我有以下SQL:

    ALTER PROCEDURE [dbo].[usp_gettasks]  
    @ID varchar(50)

    AS
     declare @PDate Date


     WHILE (DATEPART(DW, @PDate) =  1 OR DATEPART(DW, @PDate) =  7 )
     BEGIN

      set @PDate =  DATEADD(day, 1, @PDate)

     END

     CREATE VIEW tblList AS

     select tt.ItemOrder,tt.DisplayVal,  DATEADD(day, tt.DaysDue, @PDate)  from tblLine tt
     where tt.ID = 1 
Run Code Online (Sandbox Code Playgroud)

我收到以下消息:

语法错误:'Create VIEW'必须是批处理中唯一的语句

我GO之前尝试过Create View,但后来无法识别它的价值PDate.

sql-server sql-server-2008-r2

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

使用未声明的标识符'UIUserNotificationSettings'

我正在尝试使用Xcode 6编译现有的应用程序.

这是我的代码:

UIUserNotificationSettings *settings = [UIApplication.sharedApplication currentUserNotificationSettings];
Run Code Online (Sandbox Code Playgroud)

这是我的错误:

use of undeclared identifier 'UIUserNotificationSettings'
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决这个问题.

这是我对iOS 8的检查:

if (SYSTEM_VERSION_LESS_THAN(_iOS_8_0)) {

        // Displaying notifications and ringing

        if ([self isMissingMandatoryNotificationTypes:[UIApplication.sharedApplication enabledRemoteNotificationTypes]]) {

            [self registrationWithSuccess:^{
                DDLogInfo(@"Push notifications were succesfully re-enabled");
            } failure:^{
                [self.missingPermissionsAlertView show];
            }];
        }

    } else {

        // UIUserNotificationsSettings
        UIUserNotificationSettings *settings = [UIApplication.sharedApplication currentUserNotificationSettings];
Run Code Online (Sandbox Code Playgroud)

objective-c ios ios8

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

如何在 JavaFX 中使用其边框更改形状属性?

如何在 JavaFX 中使用形状的边框来更改其属性之一 - 高度、宽度、半径等。

我尝试在圆形上使用圆形来调整半径的大小,但我想知道是否可以使用形状的边框来完成。

这是我的自定义圆类:

public class NewCircle extends Circle {


public NewCircle (double x, double y , double radius, Color colore){
    super(x,y,radius);
    this.setFill(colore);
    this.setOnMousePressed(circleOnMousePressedEventHandler);
    this.setOnMouseDragged(circleOnMouseDraggedEventHandler);
    }

double orgSceneX, orgSceneY;
double orgTranslateX, orgTranslateY;

EventHandler<MouseEvent> circleOnMouseClickedEventHandler = new EventHandler<MouseEvent>(){
    @Override
    public void handle(MouseEvent t ){


    }

};


EventHandler<MouseEvent> circleOnMousePressedEventHandler = new EventHandler<MouseEvent>(){
    @Override 
    public void handle(MouseEvent t){
        orgSceneX = t.getSceneX();
        orgSceneY = t.getSceneY();
        Node source = (Node) t.getSource();
        orgTranslateX = ((Circle) (t.getSource())).getTranslateX();
        orgTranslateY = ((Circle) (t.getSource())).getTranslateY();     
        ((Circle)t.getSource()).toFront();;
    }
}; …
Run Code Online (Sandbox Code Playgroud)

java javafx

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