CooperRS / RMPickerViewController

This is an iOS control for selecting something using UIPickerView in an UIAlertController like manner
MIT License
381 stars 51 forks source link

Several errors (XCode 6.1 - Swift) #23

Closed ispiropoulos closed 9 years ago

ispiropoulos commented 9 years ago

Hello and thank you for RMPickerViewController and for RMDateSelectionViewController!

I am using RMDateSelectionViewController without any issues on my test project.

Although, when I add RMPickerViewController, I import the .h file on my bridging header I am getting the following errors:

http://i.imgur.com/69d2LIY.png

Any idea on how to resolve?

CooperRS commented 9 years ago

Hi,

I could think of two issues in this case:

1) You have a cycle in your import statements. 2) RMPickerViewController.h is imported before <UIKit/UIKit.h> is imported. In this case, defined values like YES or NO are unknown as they are defined somewhere in the depths of <Foundation/Foundation.h> which is imported by <UIKit/UIKit.h>.

Hope, this helps a bit :)

Best regards, Roland

ispiropoulos commented 9 years ago

Hello and thank you for the fast answer.

(1). The only imports I have are on my bridging header (I code in Swift)

import "RMDateSelectionViewController.h"

import "RMPickerViewController.h"

(2). I have no idea what you are talking about :tongue:

CooperRS commented 9 years ago

Whoops, I'm sorry. For some reason GitHub hides everything within < and >. I updated (2) above ;)

ispiropoulos commented 9 years ago

So, if UIKit is imported after RMPicker... how can that be changed? :\ I don't quite get it. Do I have to import UIKit.h on my Bridging header?

CooperRS commented 9 years ago

Is your bridging header a precompiled prefix header? Where do you import your bridging header in the classes that use RMDateSelectionViewController/RMPickerViewController?

ispiropoulos commented 9 years ago

When I added the RMDateSelectionViewController files, Xcode asked me If I want a bridging header, said yes, did #import "RMDateSelectionViewController.h" and it worked fine. The picker has issues.

I have not imported any bridging header into RMDateSelectionViewController/RMPickerViewController classes

ispiropoulos commented 9 years ago

Just tried it on a new clean project. Same error with the Picker.

Add the picker files in the clean project, Xcode asked me for bridging header, YES, then #import RMPickerViewController.h still gives me errors (even If I do not import RMPickerViewController.h with the bridging header)

CooperRS commented 9 years ago

Ok, can you send me that clean test project? I'll try to figure it out then ;)

ispiropoulos commented 9 years ago

There you go:

https://dl.dropboxusercontent.com/u/17257636/Sharing/pickerTest.zip

CooperRS commented 9 years ago

OK, I think I figured it out. I would like you to update to RMDateSelectionViewController 1.4.3 and RMPickerViewController 1.3.3 as they import their public header and <QuartzCore/QuartzCore.h> right after the license.

Should fix your problem :)

ispiropoulos commented 9 years ago

YES!!! Moving the imports right after the license worked! Thank you for the quick fix!!!

ispiropoulos commented 9 years ago

By the way, I haven't quite understood how to add the translations to the buttons localisation (I hard-coded them), so, If you want to do it for the Greek Language:

Now: Τώρα Cancel: Άκυρο Select: Επιλογή

Hope I' ve helped at least a bit :)

CooperRS commented 9 years ago

In Swift you could extend your app delegate like follows:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
    var localizedSelectTitle = NSLocalizedString("Select", comment: "");
    var localizedCancelTitle = NSLocalizedString("Cancel", comment: "");

    RMPickerViewController.setLocalizedTitleForSelectButton(localizedSelectTitle);
    RMPickerViewController.setLocalizedTitleForCancelButton(localizedCancelTitle);

    //Some more code...

    return true;
};

Note that your also need a Localizable.strings file (or a similar file), which contains the translations for Select and Cancel.