小编pat*_*ckd的帖子

messageComposeViewController Swift 2中的错误

以下代码适用于Swift 1.2.现在,我收到一个错误:

"MessageComposeResult类型的值没有成员'值'"

func messageComposeViewController(controller: MFMessageComposeViewController, didFinishWithResult result: MessageComposeResult) {
    switch (result.value) {
    case MessageComposeResultCancelled.value:
        print("Message was cancelled")
        self.dismissViewControllerAnimated(true, completion: nil)
    case MessageComposeResultFailed.value:
        print("Message failed")
        self.dismissViewControllerAnimated(true, completion: nil)
    case MessageComposeResultSent.value:
        print("Message was sent")
        self.dismissViewControllerAnimated(true, completion: nil)
    default:
        break;
    }
}
Run Code Online (Sandbox Code Playgroud)

为了在Swift 2中找到消息的状态,我应该检查结果的哪个成员?

ios swift swift2

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

CGPath在Swift 3中不起作用

我正在更新swift 3的代码.我已经为swift 2中的spritekit对象创建了一个自定义路径.但是,现在我得到一个编译器错误:

Nil与预期的参数类型'Unsafe Pointer CGAffineTransform'不兼容

let offsetX = player.size.width * player.anchorPoint.x
let offsetY = player.size.height * player.anchorPoint.y

let path = CGMutablePath()

CGPathMoveToPoint(path, nil, 10 - offsetX, 16 - offsetY)
CGPathAddLineToPoint(path, nil, 10 - offsetX, 0 - offsetY)
CGPathAddLineToPoint(path, nil, 24 - offsetX, 0 - offsetY)
CGPathAddLineToPoint(path, nil, 24 - offsetX, 16 - offsetY)
CGPathAddLineToPoint(path, nil, 24 - offsetX, 16 - offsetY)
CGPathAddLineToPoint(path, nil, 28 - offsetX, 40 - offsetY)
CGPathAddLineToPoint(path, nil, 18 - offsetX, 46 - offsetY)
CGPathAddLineToPoint(path, nil, …
Run Code Online (Sandbox Code Playgroud)

cgpath swift3

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

C出口的奇怪行为()

我试图用一个退出号退出我的主函数,但它总是以0退出.例如,代码:

printf("command exited with error: %i\n", commandExitError);
if(commandExitError > 0)
  exit(commandExitError);

if(openError > 0)
  exit(openError);
printf("I shouldn't see this if there was an error");
return 0;
Run Code Online (Sandbox Code Playgroud)

有一个奇怪的行为,如果commandExitError是0,但是openError是1,那么它会以错误1退出.但是,如果commandExitError大于零,它仍然以0退出!例如,这是一些输出commandExitError > 0:

命令退出并显示错误:512

请注意,我们从未达到打印声明"我不应该看到这个...."然后,获取我的程序的退出状态,回显$?

0

我们看到我的程序仍然以0退出,尽管它应该以512清楚地退出.

c exit

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

标签 统计

c ×1

cgpath ×1

exit ×1

ios ×1

swift ×1

swift2 ×1

swift3 ×1