每当我尝试构建应用程序重命名我的项目后,我得到一个 Apple Mach-O链接器错误 下面是Xcode本身的输出
Ld /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator/Broadcast!Tests.xctest/Broadcast!Tests normal x86_64
cd "/Users/joshevans/Desktop/sn app/SwifferApp"
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk
-L/Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator
-F/Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator
-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/Developer/Library/Frameworks
-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks
-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/Developer/Library/Frameworks
-filelist /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Intermediates/Broadcast!.build/Debug-iphonesimulator/Broadcast!Tests.build/Objects-normal/x86_64/Broadcast!Tests.LinkFileList
-Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -bundle_loader /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator/SwifferApp.app/SwifferApp
-Xlinker -objc_abi_version -Xlinker 2 -framework XCTest -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator
-Xlinker -add_ast_path -Xlinker /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Intermediates/Broadcast!.build/Debug-iphonesimulator/Broadcast!Tests.build/Objects-normal/x86_64/Broadcast_Tests.swiftmodule
-mios-simulator-version-min=8.0 -Xlinker -dependency_info -Xlinker /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Intermediates/Broadcast!.build/Debug-iphonesimulator/Broadcast!Tests.build/Objects-normal/x86_64/Broadcast!Tests_dependency_info.dat
-o /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator/Broadcast!Tests.xctest/Broadcast!Tests ld: file not found: /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator/SwifferApp.app/SwifferApp clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助,因为我是Xcode和快速语言的新手.玩笑
究竟是怎么回事 DispatchTime.now()
为什么我不能指定等待变量的时间?
我怎么能使用变量?
给出错误>>>
二进制运算符'+'不能应用于'DispatchTime'和'Float'类型的操作数
var time : Float = 2.2 // <---time
@IBAction func buttonPressed(_ sender: Any) {
let when = DispatchTime.now() + 2.2 // <---- THIS IS OKAY
DispatchQueue.main.asyncAfter(deadline: when){
print("Hello")
}
let whenWhen = DispatchTime.now() + time // <---- THIS IS NOT OKAY
DispatchQueue.main.asyncAfter(deadline: whenWhen){
print("Hello")
}
}
Run Code Online (Sandbox Code Playgroud) 我目前正在使用a UILabel来显示多行文本.断行最多设置为,NSLineBreakByWordWrapping因此标签会自动插入换行符.如何检测这些换行符的位置?基本上,我想返回包含每个\n中断的字符串.
就像它在标题中所说,我试图在点击按钮时更改标签文本.行出现错误self.playerChoice.text = "You: Rock"
import UIKit
class ViewController: UIViewController {
var player : Int = Int()
@IBOutlet weak var readyLabel: UILabel!
@IBAction func noButton(sender: AnyObject) {
exit(0)
}
// ---------------------------------------------------------
@IBOutlet var computerChoice: UILabel!
@IBOutlet var playerChoice: UILabel!
@IBOutlet var score: UILabel!
// Variables -------------------------------------------------
let Rock : String = "Rock"
let Paper : String = "Paper"
let Scissors : String = "Scissors"
//------------------------------------------------------------
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically …Run Code Online (Sandbox Code Playgroud) 我有这个扩展,它将创建一个新的数组,其中包含从给定数组中随机组的数组:
extension Array {
var shuffle:[Element] {
var elements = self
for index in 0..<elements.count {
swap(&elements[index], &elements[ Int(arc4random_uniform(UInt32(elements.count-index)))+index ])
}
return elements
}
func groupOf(n:Int)-> [[Element]] {
var result:[[Element]]=[]
for i in 0...(count/n)-1 {
var tempArray:[Element] = []
for index in 0...n-1 {
tempArray.append(self[index+(i*n)])
}
result.append(tempArray)
}
return result
}
}
Run Code Online (Sandbox Code Playgroud)
我这样使用它:
let mainArr = Array(1...60)
let suffeldArr = mainArr.shuffle.groupOf(10)
print(suffeldArr)
Run Code Online (Sandbox Code Playgroud)
它将打印如下:
[[10 random element between 1 to 60], [10 random element between 1 to 60], [10 random element …Run Code Online (Sandbox Code Playgroud) 我尝试使用下面的代码在屏幕上创建一个连续旋转的方块.但我不知道为什么转速在变化.如何更改代码以使旋转速度不变?我尝试了不同UIViewKeyframeAnimationOptions,但似乎没有一个工作.
override func viewDidLoad() {
super.viewDidLoad()
let square = UIView()
square.frame = CGRect(x: 55, y: 300, width: 40, height: 40)
square.backgroundColor = UIColor.redColor()
self.view.addSubview(square)
let duration = 1.0
let delay = 0.0
let options = UIViewKeyframeAnimationOptions.Repeat
UIView.animateKeyframesWithDuration(duration, delay: delay, options: options, animations: {
let fullRotation = CGFloat(M_PI * 2)
UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 1/3, animations: {
square.transform = CGAffineTransformMakeRotation(1/3 * fullRotation)
})
UIView.addKeyframeWithRelativeStartTime(1/3, relativeDuration: 1/3, animations: {
square.transform = CGAffineTransformMakeRotation(2/3 * fullRotation)
})
UIView.addKeyframeWithRelativeStartTime(2/3, relativeDuration: 1/3, animations: {
square.transform = …Run Code Online (Sandbox Code Playgroud) 我有一个Swift应用程序,我有一个PFQueryTableViewController,我想使用本地数据存储区与Parse.但是,我对使用本地数据存储区和实时查询感到困惑.
这是我想做的事情:
PFQueryTableViewController显示,我想它总是从本地数据存储中获取数据我该如何实现这一目标?
我正在按照本教程使用以下代码实现该动画:
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.layer.transform = CATransform3DMakeScale(0.1,0.1,1)
UIView.animateWithDuration(0.25, animations: {
cell.layer.transform = CATransform3DMakeScale(1,1,1)
})
}
Run Code Online (Sandbox Code Playgroud)
但是我想在这个单元格动画中更新一些内容,比如当我滚动到tableView时,单元格像(0.1,0.1,1)开始时一样小,之后它会缩放,(1,1,1)但我想应用像气泡类型的效果,因为它在开始之后它很小它的原始缩放比例(1,1,1)和一个它是缩放,它再次进入其原始尺度(1,1,1).
请指导我如何实现该动画?
编辑:
我试过这个,但它不是那么顺利,不是我想要的.
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.layer.transform = CATransform3DMakeScale(0.1,0.1,1)
UIView.animateWithDuration(0.3, animations: {
cell.layer.transform = CATransform3DMakeScale(1,1,1)
})
UIView.animateWithDuration(1, animations: {
cell.layer.transform = CATransform3DMakeScale(2,2,2)
})
UIView.animateWithDuration(0.3, animations: {
cell.layer.transform = CATransform3DMakeScale(1,1,1)
})
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用if语句检查是否存在url图像.但是,当尝试通过错误的图像url测试它时,它会继续返回:
致命错误:在展开Optional值时意外发现nil.
码:
var httpUrl = subJson["image_url"].stringValue
let url = NSURL(string: httpUrl)
let data = NSData(contentsOfURL: url!)
if UIImage(data: data!) != nil {
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试与我共享我的应用程序URL,UIActivityViewController这是我的代码:
let items = [URL(string: "https://itunes.apple.com/de/app/idxxxxxxxxx")!]
let ac = UIActivityViewController(activityItems: items, applicationActivities: nil)
present(ac, animated: true)
Run Code Online (Sandbox Code Playgroud)
应用程序URL在浏览器上运行良好。但在 iPhone 上崩溃。
这是我在控制台中获得的日志:
ACAccountStore:[66A6F31E] 无法保存帐户。帐户 = | error = Error Domain=com.apple.accounts Code=7 “该应用程序无权访问 iTunes Store 帐户” UserInfo={NSLocalizedDescription=该应用程序无权访问 iTunes Store 帐户}
[accounts] ACAccountStore:无法创建本地帐户。error = Error Domain=com.apple.accounts Code=7 “该应用程序无权访问 iTunes Store 帐户” UserInfo={NSLocalizedDescription=该应用程序无权访问 iTunes Store 帐户}