I am trying to localize a class (.h & .m files) in my application. I made the same operation as when I localized my interface (xib -> Get info -> make file localizable). I created a second .h and a second .m file, and I made the modifications I needed for the new location. Great !
But it just doesn't work...
I get the error:
duplicate symbol _OBJC_METACLASS_
Does anyone have a clue ? Thanks a lot !
you are just on the wrong path..
For localization you need not create separate .m & .h files.Only Xibs are to be created.
Other than that you have to create separate Localizable.strings file for each localization.
For more understanding just chk out this link http://www.switchonthecode.com/tutorials/a-simple-localization-example-for-the-iphone
It contains the link for downloading the sample code also.
Related
Can anyone tell me how can I use swift file into my objective-C project?
I have a swift file which inherits from UIViewController instead of NSObject. I am trying to use the swift file but I am not able to figure out how.
When I add my swift file into objective-C project, it usually asks to create a bridging header.
In that header file I am importing my swift file as -
#import "SlideController.swift"
and my bridging file name is objcToSwift-Bridging-Header.h
I read many answers which asks to import file
#import "MyProductModuleName-Swift.h"
into the .m file, but I can't find any such file in my project.
I also changed the defines module = YES as shown in another answer.
But still I am not able to access swift file.
What am I missing? Please tell me the right steps to figure it out.
After you created Bridging header.
Go to Build Setting =>Search for "Objective-C Bridging Header"
Just below you will find ""Objective-C Generated Interface Header Name" file
and import That file in your view controller.
ex.In my case: "Dauble-Swift.h"
I need to add a new viewController (new file h. and m.) using xCode 6 beta. After I go to File > New > File I do not get the option to add an "Object-C class" as I used to do in xCode 5. Doing that I normally got a new h. and m. file appearing in the Navigation area.
Any one can help pls?
PS - I am a beginner trying to learn basics of "storyboard" :)
thanks
If you choose objective-c File in your screenshot , you will get a .m file and a .h file written in Objective-C
If you choose Cocoa Touch File , you will have a option of Objective-C and Swift File which can be subclasses of other cocoa touch classes such as UIViewController or UITableViewCell.
IF you choose Swift File , you will get a single empty Swift file.
Since you are a beginner writing code with Objective-C , you'd better choose Objective-c File directly
Right click on the group (folder) in the navigation area in which you want to add the new viewController. Select New File, and then select Cocoa Touch Class.
I have an app with two localizations.
Usually I use 'NSLocalizedString' and keep the same source code for both localizations, but one of my ViewControllers has to look and function different for each locale.
So I pressed 'Localize..' and created two localized versions of it. Normal stuff.
Since then - on runtime I get:
Unknown class MyViewController in Interface Builder file.
and the viewcontroller is not displayed (it's a UITableViewController if it matters).
I checked in my storyboard and the custom class is still listed & linked to the view controller display. I didn't change the class name in each locale - it's still the same.
what gives here?
thanks
i experimented this kind of problem in my project and my problem was my viewcontrollers .m file was not included in the compile sources in Build Phases->Compile Sources i manually add it to the Compile Sources and problem solved for me.
i hope it will help you.
Trying to make an existing app having two different set of .h .m and .xib files for each view. Now for a single view am using only one .h & .m file and two .xib file.
eg.
ViewController.h, ViewController.m, ViewController~iphone.xib, ViewController~ipad.xib
Problem: At compile time i get errors for the files in my code i have not set their target for iphone and ipad both.
Go to Project -> Targets -> Build Settings -> Targeted Device Family . Set it to iPhone/iPad.
Enjoy Programming!!
Better solution is add target device for existing class
I am working on an application where i have to use several constants.I want to declare all those constants in one single .h file.Can any one suggest me a way to achieve this.
Thanks in advance.
You can define all required header files and constants in the ProjectName_Prefix.pch(located under the Other Sources folder of your project) file.In this way you are not required to declare the libraries,constants required in multiple classes.
Cheers
create constants.h put all you constants into it and #import "constants.h" in your Prefix.pch
or if you don't want to recompile the whole project if you change something in constants.h just import the file in the sourcefiles where you need it.
The latter approach saves a lot of time if you use an old mac mini for development on a project which has 200MB of png files.