Showing posts with label IOS. Show all posts

‘Windows Bridge For iOS’ To Help iOS Developers With App Portability





What is WinObjC?

                Microsoft has released software to reduce the gap between Windows applications and apps for Apple's iOS mobile platform which is nicknamed as WinObjC.

iOS Development Beginner Tutorial 3 - Working With Storyboard

In this iOS Development Tutorial let's go deep into the Storyboard concept that Apple introduced few years ago.
Let's create a new project & here you can see the default Storyboard screen.




You can change the default Storyboard to your custom created Storyboard in Project Settings --> General Tab --> Main Interface



If you are going to create an App with only Single screen you can use this default screen as your single screen. But most of the times you will end up with so many screens in the app. To Navigate through those screens iOS Apps have 2 default ways. They are,


  • Navigation Controller
  • Tab Bar Controller
Here is an example of Navigation Controller in iOS.
 
 
 Here is an example of Tab Bar Controller in iOS.


Now you have an idea of what are those Controllers. Let's implement Navigation Controller first in our sample App.
Select the ViewContoller View you want to add Navigation Controller & then go to Editor in the Menu bar & select Embed In.  Now you can see both Navigation Controller & Tab Bar Controller. Select Navigation Controller from there.
 
 

Now you can see Xcode automatically creates the Navigation Controller for you.
To Show you how Navigation Controller works, I'm going to add a new ViewController to the StoryBoard. You can easily add a ViewController by drag & drop a new ViewController from here.
 

 


And then I'm going to change both ViewController Background colours.
 
 


Then I'm going to add a Button to the 1st ViewController & when I touch that Button I want to navigate to the 2nd ViewController.
 
 
To setup the navigation Press Control on the keyboard & drag the Button to 2nd ViewController. Now you can see a dialog box as follow.
  
In that dialog box select Show. Now you have completed the Navigation controller combination with Storyboard. Here is how it works in the Simulator. 
 
It automatically creates thousands of codes & you just need to put a button to create the navigation. 
Tab Bar also works as same. Let's add a Tab Bar Controller to 2nd ViewContoller. After adding it, the storyboard will look like this.
 
 


Let's add 2 more ViewControllers to the storyboard & Now I'm going to add those 2 new ViewControllers to the TabBar Controller. 
 
 
To add new ViewControllers to the TabBar Controller press Control button on the keyboard & drag TabBarController to a new ViewController.
  
In that dialog box select View Controllers. Do the same steps to the next ViewController as well. Now you can see it automatically creates all the connections related to Tab Bar Controller.
 
 
To see this, let's run the project in a simulator. Here you can see, when you navigate to the 2nd ViewController there is a Tab Bar inside the View & you can switch between Views using the Tab Bar.
  
This is how the Navigation Controller & Tab Bar Controller works in Storyboard. If you are not using Storyboard & keen to use XIB, there is a programmatically way of implementing those 2 Controllers as well. I'll discuss about them later in this tutorial series.
 
Dilum BC Navanjana
[CIS 2010/2011]
Associate Software Engineer(iOS), 
Creation Application
dilum@creationapplication.com 


 

iOS Development Beginner Tutorial 2 - MVC in iOS Development

MVC is a strategy how to organise all the classes in your application. All the classes in a app has 3 camps. They are, 
  1. Model - Model is what is your program. Model is UI independent.
  2. Controller - How something draw in your screen is the Controller’s job.
  3. View - View is the building block of the UI. Stuff in your view is generic
To know MVC correct you have to study how those 3 elements communicate with each other. 
Let’s talk about Controller talks to the Model. Controller can directly talks with Model. In the above picture also you can see it clearly. It’s a full unrestricted access. As well as Controller also can talk directly to their View. It layout the user interface to the View to draw in the screen. You can see, there is a name called “Outlet” in the start of that arrow. When we have a property of a controller that point in to the View we call it Outlet.The Model and View should never speak to each other. Model is 100% UI independent. There is no way Model can talk to View. View want to go through Controller to talk to the Model.

View can communicate with the Controller in a blind way. They don’t know the class they talking to. It’s a structured way. Controller has a target & the View has a action. That action can only go the that target. The View sends the action when things happen in the UI. When the View has some complicated ways to communicate. The Controller sets itself as the View’s delegate on those occasions. In the above picture with the Yellow arrow you can see a delegate. Delegation also a blind communication way. And also Views do not own the data they display. When you see something in your screen, it’s not the View’s data. The data is owned by the Model & Controller give those data to the View from Model. To get those data from the Model, View has to use Data Source. Data Source is just a kind of delegate, it’s a specific delegate. In building iOS apps you have to use delegates & also data sources.

Can the Model communicate to the Controller? Good questions. But when we are building apps we have some situations that Model want to communicate to Controller. For example think about a online radio streaming app. When the stream gives data to the Model, Model wants to communicate with the Controller & want to send those data to the Controller. How do we do that communication? It’s similar to radio station broadcast. The mechanism for doing this in iOS is called Notification & KVO. So the model changes, it broadcast that change & Controller tune in to interesting stuff.



This is how MVC works in iOS app development. Hope this will be helpful for your knowledge.


Dilum BC Navanjana
[CIS 2010/2011]
Associate Software Engineer(iOS), 
Creation Application
dilum@creationapplication.com

iOS Development Beginner Tutorial 1 - Create a new iOS Project



This is the first Tutorial of a series of iOS Development. Before go deep into iOS Development let's start learning from basics.

iOS Development requires Xcode as the IDE. First of all you have to download Xcode from Apple Developer Website. I'm using Xcode 6.1.1 for this tutorial.


After downloading Xcode, you can install it & then you can see the Xcode icon on the Application List. Once you open Xcode, you can see like this.



Let's create a new Xcode project by selecting Create a New Xcode Project. Then this window comes to the screen & from this screen you can select the type of project you want.



You can choose OS X projects as well. But for this tutorial I'm going to select iOS Application & Single View Application

Then Select Next, from this window you can give your project a name & change some configurations. I named my project as iOSTutoria1.




Then you can select where do you want to save this project & click Create.
Here is the first project screen you can see after creating the project. In the left side of the screen you can see the Project Navigator. In the right side of the screen you can see some other project settings as well.



For first set of tutorials I'm going to use Storyboard method. Main.storyboard is the storyboard of the Application. You can create all of your screens inside the storyboard & connect screens as you want as well.

Storyboard looks like this. As you can see in the bottom right corner of the screen you can add more View Controllers to the project. I'll talk more about View Controllers in next tutorial sessions.



Here I add new View Controllers to the storyboard & this is how it looks like now. But I didn't connect those View Controllers, so if I run the App now, you can only see the top left corner View Controller.



As the last part of the tutorial I'm going to run this application in Xcode simulator & here is that coloured screen come.




Dilum BC Navanjana 
[CIS 2010/2011]
Associate Software Engineer(iOS), 
Creation Application
dilum@creationapplication.com