所以我回去重新编写了我的代码并确保参数都在正确的位置。但是现在,当我在iOS模拟器中运行我的应用程序时,我得到一个线程1:信号SIGABRT错误以及我的调试区域中的以下错误:
2014-11-04 00:39:12.288 Juxta[60526:1144351] +[_TtCFC5Juxta14ViewController11viewDidLoadFS0_FT_T_L_7Counter parseClassName]: unrecognized selector sent to class 0x1059bb640
2014-11-04 00:39:12.291 Juxta[60526:1144351] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[_TtCFC5Juxta14ViewController11viewDidLoadFS0_FT_T_L_7Counter parseClassName]: unrecognized selector sent to class 0x1059bb640'
*** First throw call stack:
(
0 CoreFoundation 0x0000000106c183f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000108746bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000106c1f40d +[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000106b777fc ___forwarding___ + 988
4 CoreFoundation 0x0000000106b77398 _CF_forwarding_prep_0 + 120
5 Juxta 0x00000001057e2812 -[PFObject(Private) init] + 143
6 Juxta 0x00000001057d59f0 _TFCFC5Juxta14ViewController11viewDidLoadFS0_FT_T_L_7CountercfMS1_FT_S1_ + 64
7 Juxta 0x00000001057d5a32 _TFCFC5Juxta14ViewController11viewDidLoadFS0_FT_T_L_7CounterCfMS1_FT_S1_ + 50
8 Juxta 0x00000001057d44a7 _TFC5Juxta14ViewController11viewDidLoadfS0_FT_T_ + 1575
9 Juxta 0x00000001057d47f2 _TToFC5Juxta14ViewController11viewDidLoadfS0_FT_T_ + 34
10 UIKit 0x00000001075c7190 -[UIViewController loadViewIfRequired] + 738
11 UIKit 0x00000001075c738e -[UIViewController view] + 27
12 UIKit 0x00000001074e6db9 -[UIWindow addRootViewControllerViewIfPossible] + 58
13 UIKit 0x00000001074e7152 -[UIWindow _setHidden:forced:] + 276
14 UIKit 0x00000001074f365c -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x000000010749e191 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2628
16 UIKit 0x00000001074a0e5c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1350
17 UIKit 0x000000010749fd22 -[UIApplication workspaceDidEndTransaction:] + 179
18 FrontBoardServices 0x000000010c3472a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
19 CoreFoundation 0x0000000106b4dabc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
20 CoreFoundation 0x0000000106b43805 __CFRunLoopDoBlocks + 341
21 CoreFoundation 0x0000000106b435c5 __CFRunLoopRun + 2389
22 CoreFoundation 0x0000000106b42a06 CFRunLoopRunSpecific + 470
23 UIKit 0x000000010749f799 -[UIApplication _run] + 413
24 UIKit 0x00000001074a2550 UIApplicationMain + 1282
25 Juxta 0x00000001057d6e7e top_level_code + 78
26 Juxta 0x00000001057d6eba main + 42
27 libdyld.dylib 0x00000001097a8145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
这是我的代码,所以更清楚:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var testObject = PFObject(className: "TestObject")
testObject["foo"] = "bar"
testObject.saveInBackgroundWithTarget(nil, selector: nil)
class Counter : PFObject {
var voteCount: Int = 0
func incrementBy(amount: Int, numberOfTimes times: Int) { voteCount += amount * times
println(" \(voteCount) votes")
}
}
var countOption1 = PFObject(className: "countOption1")
countOption1 = Counter()
countOption1.saveInBackgroundWithTarget(PFObject.self, selector: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
有关我的代码可能出错的任何提示吗?这次我非常小心。
答案 0 :(得分:0)
你必须犯了一些复制和粘贴错误。例如,没有理由:
class Counter
在UIViewController
class Counter
有一个didReceiveMemoryWarning
函数
class Counter
函数中的另一个countOption1
。
这是一团糟