我一直在努力,在StackOverflow上查找了与此问题相关的所有类似问题并尝试无效。
class TimeLineTableViewController: UITableViewController,
UIImagePickerControllerDelegate, UINavigationControllerDelegate {
var timelineData = [PFObject]()
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
self.loadData()
}
@IBAction func loadData(){
timelineData.removeAll(keepCapacity: false)
var findTimelineData:PFQuery = PFQuery(className:"timelineMessages")
findTimelineData.findObjectsInBackgroundWithBlock
{
(objects:[AnyObject]! , error:NSError!) -> Void in
if error == nil
{
self.timelineData = objects.reverse() as [PFObject]
//let array:NSArray = self.timelineData.reverseObjectEnumerator().allObjects
// self.timelineData = array as NSMutableArray
self.tableView.reloadData()
}
}
}
override func viewDidAppear(animated: Bool) {
var footerView:UIView = UIView(frame: CGRectMake(0, 0, self.view.frame.size.width, 50))
self.tableView.tableFooterView = footerView
var logoutButton:UIButton = UIButton.buttonWithType(UIButtonType.System) as UIButton
logoutButton.frame = CGRectMake(20, 10, 50, 20)
logoutButton.setTitle("Logout", forState: UIControlState.Normal)
logoutButton.addTarget(self, action:"logout:", forControlEvents: UIControlEvents.TouchUpInside)
footerView.addSubview(logoutButton)
}
为了澄清,timelineTableViewController有一个继承的类,MessageTableCell。它也是我已经集成到Objective-C代码中的项目的一部分,因此它是Swift和ObjC的组合。我独立运行了两个项目(快速项目和ObjC项目),它们运行良好;只有当我试图一起运行它们才会搞砸它们。有什么建议?我完全失去了这一点。
答案 0 :(得分:41)
“与Objective-C中的子类不同,Swift子类默认不继承它们的超类初始化器。”
自动初始化程序继承
摘自:Apple Inc.“The Swift Programming Language。”iBooks。 https://itun.es/tw/jEUH0.l
由于您已覆盖init(coder aDecoder: NSCoder)
,TimeLineTableViewController
无法获得init()
初始化。
您可以提供其所有超类指定初始化程序的实现,例如
override init() {
super.init()
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
,或者只是删除init(coder aDecoder: NSCoder)
的实现。
答案 1 :(得分:0)
我的2美分用于“采样器演示”(AudioKit-4.11.2)和Xcode 12.0
class Conductor {
private var sequencer: AKAppleSequencer!
private var mixer = AKMixer()
private var arpeggioSynthesizer = AKMIDISampler(**midiOutputName: nil**)
private var padSynthesizer = AKMIDISampler(**midiOutputName: nil**)
private var bassSynthesizer = AKMIDISampler(**midiOutputName: nil**)
private var drumKit = AKMIDISampler(**midiOutputName: nil**)
private var filter: AKMoogLadder?
....