Friday, 20 June 2014

Hi everyone ,

          This is the post to to create and use Objective C class object in Swift class and swift object in Objective C class .

Here is our App ....




here the First screen has created using Swift , The the second screen using Objective C and the last screen using Swift language .


           Let's start our implementing  

For the Swift language we have to use xcode 6 or later versions , Here we are using Xcode 6 ,
create a new Xcode project .....


select "Single view application" option


and give a suitable product name Here it is Hello1 , give Organization name ,   Organization identifier and finally language is Swift , Dives is iPhone


Click on NEXT and select location and FINISH it .


It will open your Xcode project.


In that project we get Mainly 3 files called AppDeligate.swift , ViewController.swift and Main.Storyboard .

First select your Main.storyboard file and drag and drop one Label and one Button , name label as First Screen and button as Next .

select "assistant editor" (second option ) in right top menu

it will show editor like this

now we have to create onClick Method to button , select your next button on storyboard file , press control button  and press your mouse left button on "next button " and drag to right inside to class .
     
                  We will got a box like ,

select ACTION for CONNECTION , and give a proper name for button action and click on connect
then i t will create a method like

@IBAction func theNextButtonMethod(sender: AnyObject) {
        
       

    }



                           Create a new file in project ....

and select a new cocoa touch file ..........

click on next , and give class name , select language as objective C , click on next 

it will show a popup box select on YES ....


                     It will create new objective C class and "Hello1-bridging-header.h" , in that file import "#import "HelloOBJC_Class.h"