1

This entire question premise might be completely ridden with issues due to the fact that I am updating a project written in Objective-C with Swift.

First off, I am trying to access methods belonging to a class written in Objective-C from a Swift subclass that has inherited it. However there are some methods that I can see and access but others are invisible (act as if they do not exist).

The .h file for the Objective-C class is as follows:

#import <UIKit/UIKit.h>

@interface BaseMenuViewController : UIViewController

-(void)applyColourForeground:(UIColor *)foreground background:(UIColor *)background;
-(void)colorButton:(UIButton *)button foreground:(UIColor *)foreground background:(UIColor *)background;
- (void)spreadElementsVertical:(UIView *)firstArg, ...;
- (void)spreadElementsVerticalWithSeparation:(CGFloat)separation elements:(UIView *)firstArg, ...;
@end

The Swift class looks like this:

import UIKit

class FontViewController: BaseMenuViewController {

    var BackButton: UIButton

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)

    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()

    }

}

The first two methods applyColourForeground and colorButton are both visible and callable from my Swift subclass but the other two spreadElementsVertical and spreadElementsVerticalWithSeparation are not. I am attempting to access them via super.<function> and BaseMenuViewController.<function> where <function> is the name of each method but the IDE only shows the aforementioned two.

What am I missing?

Any help is appreciated.

Shiri
  • 1,972
  • 7
  • 24
  • 46
  • 1
    The problem is that functions taking a *variable argument list* (such as `(UIView *)firstArg, ...`) are not imported to Swift, see e.g. http://stackoverflow.com/questions/33194791/how-can-i-use-syslog-in-swift for a similar issue. You'll have to write an Objective-C wrapper function which takes a `va_list` parameter. – Martin R Jun 27 '16 at 14:22

0 Answers0