简体   繁体   English

如何将Objective-C行转换为Swift?

[英]How to convert Objective-C line to Swift?

I have code in Objective C: 我在目标C中有代码:

NSMutableArray* paths = [textView.textContainer.exclusionPaths mutableCopy];

and now when I try to convert it to Swift: 现在,当我尝试将其转换为Swift时:

self.textView.textContainer.exclusionPaths(mutableCopy())

it gives me error: 它给我错误:

Cannot call value of non-function type '[UIBezierPath]'

How can I convert it? 如何转换?

Also I tried: 我也尝试过:

self.textView.textContainer.exclusionPaths.mutableCopy()

but exclusionPaths does not have mutableCopy() method 但是exclusionPaths没有mutableCopy()方法

Simply do: 只需做:

var paths = textView.textContainer.exclusionPaths

This will give you a mutable copy of the original array of paths. 这将为您提供原始路径数组的可变副本。

在Swift中,仅使用var关键字声明一个可变类型

var paths = textView.textContainer.exclusionPaths

使用Array(textView.textContainer.exclusionPaths)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM