Showing posts with label iOS development. Show all posts
Showing posts with label iOS development. Show all posts

Wednesday, 7 December 2016

Let's play with Classes and Objects... :)


Hello Friends,

So far we have seen what is iOS , why to choose iOS developer as a profession, objective c overview also we made some new friends from objective c world i.e objective c syntaxes. So our journey has already started and we are enjoying the the path to destination .

As we are now familiar with the required syntax of objective c, I think now it's time to create our first class . We will be discussing about how to create classes , how to proceed for the class creation, how to decide the structure of class etc. So let's start...!!



Before going for coding , I would like to share my experience about dealing with classes. Like most of us, I have completed my Engineering in Computer Science. But being honest, till the end completion of four years of my engineering , I didn't know how to relate classes and objects in our real life scenarios. All I used to do is only study some popular example from the books and use them everywhere. So when I started learning OOP , it was very hard for to understand the use of classes and objects in real IT industry working. I used to think like how can we build a softwares or applications by just creating their blueprint on paper?? How can I describe a real life object in terms of coding? I have faced all such and many more doubts, so I wanted to clarify them as somebody may find it helpful at the earlier stage .




When we proceed for converting real life objects into programming , always sit back for few minutes and think about all the possible features that object can have in real life. For example , if we have to represent  Football in terms of coding. Start by writing down all the possible feature a football can have. Few of them can be color, size,manufacturer company, weight etc and the functions it can have will consists bouncing behaviour that is a football bounces.
Now we are clear about the properties and functionalities of the football object, we will proceed to create its object. Always create a class to represent such real life entity (Football in our case). So we will create a class whose name will be Football . We know that class is a collection of properties and functions, so we will create variables and constants of all the features/properties of Football and finally we will describe it's behaviour by creating a method called bounce.

You can see this thinking process in the above figure.

I hope you have got some idea about how to proceed for designing class structure.Now lets dive into coding . For better understanding we will create Student class and its objects.





Now the very first step we will do is , write down all the possible  features and functions of a student.
The list will look somewhat like this:

Properties:

1. Name
2. Roll Number
3. Address
4. Divison

Functions:

1. Do Homework
2. Write an examination
3. Play

We are now all set with the blueprint, so we can proceed for the coding.

First we will design the class.

Class declaration:


#import <Foundation/Foundation.h>//we will see about this in coming posts.For now you can ignore it

@interface Student : NSObject 
{
    //Properties
    int rollNumber;
    NSString *name;
    NSString *address;

}

//Functions (more appropriately Methods)
-(void)writeExamination;
-(void)doHomework;
-(void)play;

@end

You can now easily correlate the Student from real life with the class we have just designed.
This is just the class design, yet we will have to write its implementation.

Class implementation:



@implementation Student

//This is like constructor in other languages.
- (instancetype)initWithName:(NSString*)studentName rollNumber:(int)studentRollNumber andAddress:(NSString*)studentAddress
{
    self = [super init];
    if (self) {
        rollNumber = studentRollNumber;
        name = studentName;
        address = studentAddress;
    }
    return self;
}

-(void)writeExamination{
    //your logic here
}
-(void)doHomework{
    //your logic here
}
-(void)play{
    //your logic here
}

@end

The implementation will explain how exactly the methods are going to work. For example we can provide steps for writing an examination in writeExamination method.

We are ready with the blueprint and the implementation , so its time to use it with the help of an Object as we know class is nothing without its object.


int main(int argc, const char * argv[]) {
    //Here we are creating object of the student class
    Student *jenna = [[Student alloc]initWithName:@"Jenna" rollNumber:1 andAddress:@"Pune"];
    Student *john = [[Student alloc]initWithName:@"John" rollNumber:2 andAddress:@"Pune"];
  
/*
 alloc - is like malloc in C++, it allocates memory for   object.
 init - this method initialises the properties of a class with their default values.
 */
    
    [jenna doHomework];//Method calling with the help of object
    [jenna play];
    
    [john writeExamination];
    [john doHomework];
    [john play];
    
    return 0;
}


I have written comments wherever necessary. Yes, there are few things here which you will not find in any other programming language like alloc , NSObject , we are going to see all these in the coming posts. As this post was specifically for understanding classes and objects in action, so I have not explained those things here .

See you in the next post, till then Happy Coding..!!


Share:

Monday, 5 December 2016

Friendship with Objective - C Syntax

Hello Friends,

In my previous post on OOP Concepts, I have explained the most widely used features of OOPs with 
real time examples to easily co-relate the programming in our daily life scenarios.

Also I have briefly explained about Objective - C overview and Why to choose iOS developer as a career, in my initial posts. Now as you are clear about the purpose of learning iOS development, from here onwards we will be discussing about iOS Development using Objective - C and Swift languages.

So lets start our journey by making some new friends who will be there till the end of our iOS development. These new friends are nothing but the Syntax of Objective - C and Swift.
Today we will be exploring Objective - C syntax.

Before showing you the syntaxes used in objective c , lets see few important things :


  • Objective C is case sensitive language. It means myVariable and MyVariable will be considered as two variables .
  • Every line in objective c ends with semicolon ( ; ).
  • There are some reserved keywords which we can't use as variable or constant names in our program.Below is the list of those keywords. So avoid to use them as the compile will complain about their use.



Fig. Objective - C reserved Keywords

1.Variables and constants 

Variables:

datatype variableName = valueToassign;
ex.  int myNumber = 123;

In the above statement, int is the datatype of the myNumber variable and at the same time it is being initialised with the value of 123;


Constants 

There are two ways to declare a constant:

1. Using const keyword

const datatype variableName = valueToassign;

ex. const int myConstant = 12;

Here  const keywords indicated that myConstant is a constant and has a value of 12. We can't change value of a constant.

2. Using #define

#define identifier value
ex. #define  PI  3.147;


2. Methods or Function 

A function is nothing but the set of statements to perform a specific task. We normally divide our program into functions for code readability and reusability. A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function.In Objective-C, we call the function as method.
- (return_type) method_name:( argumentType1 )argumentName1 
joiningArgument2:( argumentType2 )argumentName2 ... 
joiningArgument_n:( argumentType_n )argumentName_n 
{
   body of the function
}

For ex. 

- (void) callPerson (Nsstring*) personaName   withPhoneNumber : (Nsstring*) phoneNumber
{
 NSLog(@"Write method implementation here..!!");
}



How to call a method ?

-(int) [personObject callPerson:@"Vishal" withPhoneNumber: @"9876543210"];


3. Class and object 

Class declaration


@interface MyClass:NSObject 
-(void)MyMethod
@end

Class Implementation

@implementation MyClass
- (void)MyMethod
{
   body of the function
}

Object declaration

MyClass * myClassObject = [[MyClass alloc]init];                           

NOTE: Don't be scared about words like alloc , init, @interface,@implementation here. These are only keywords and we are going to see them i detail in coming posts. :) 


I have not included other syntaxes here like syntax for loop statements , enums etc. as we are going to explore theme in our iOS journey. My motto for this post was just to introduce you with the syntax of Objective C and I strongly believe that to start any coding, the above three syntaxes are enough.

For today that's it. We will write our first class in the next post and will make our hands dirty here onwards. 

Happy Coding...!!! 



Share:

Friday, 2 December 2016

OOP (OBJECT ORIENTED PROGRAMMIMG) CONCEPTS

Hello friends,

Today I am going to discuss about the most used programming paradigm i.e Object Oriented Programming (OOP).

There are basically two types of programming paradigms:

1) Procedure Oriented Programming
2) Object Oriented Programming

As this post is regarding OOP concepts, I will not discuss more about the procedure oriented programming, so below is just a simple comparison between both of theme.

Procedure Oriented Programming VS  Object Oriented Programming

Fig. OOP V/S PROCEDURAL PROGRAMMING

Now lets move on to the basic OOP concepts. But before that lets know about classes and objects.

What is a Class and Object..???

A class is used in object-oriented programming to describe one or more objects. It serves as a template for creating, or instantiating, specific objects within a program.

In short we can say that a Class is a blueprint for object creation. Class has no meaning if we don't have its' object.

To understand it better, lets take an example from our real life scenario.
Suppose an architect has to build a house for one of his clients. What will he do first is, he will create a blue print of the plan. Once he finalises all things ,like number of rooms, area for per room, terrace section, garden etc. the workers will start executing  the same plan in reality. It means the plan is blue print and the house which is going to be build is the object of that blue print. Unless and until workers build the house , that plan has no meaning. Again the architect can use the same plan to construct number of houses .

So in short, the plan is a Class and the house is an object of that Class.

Fig. CLASSES AND OBJECT IN REAL WORLD

The book definitions for class and object are :

Class: A class can be defined as a template/blueprint that describes the behavior/state that the object of its type support.

Object : Object is an instance of a class.

Now lets see the most important OOP concepts

1) Abstraction: 


Abstraction can be defined as the way of presenting necessary things by hiding unnecessary things.

For example consider a mobile phone. As a End user we have been provided a user interface like back button, app icons to launch app, call button,valume keys etc. We just press one of these to perform certain task. Lets say we want to make a call, we will just select a contact and press call button. This will do our job of calling someone. But we don't know how exactly the call is connected to the other person, how the data is transmitted etc. So these are the unnecessary informations from the user perspective and thats why these are hidden.







                                       

                                                             Fig. ABSTRACTION



Another example is restaurant. When we go to restaurant we are given a menu card. We order something from the menu card and we are served with the dishes.
Here the dish is the necessary thing that the customer is interested in. The cooking procedure of the dish is not necessary for the customer. So its the abstraction.


                          

Fig. ABSTRACTION

2) Inheritance: 

Inheritance means acquiring properties of parent class. The derived class has all the properties of base class plus its own properties.

For example , lets say in a Company there are employees with different roles such as Marketing Executive, Developer, Cashier etc. They all are employees but in addition to that they have some specific roles which they have to perform . So here the employee is the base class and the Marketing Executive, Developer, Cashier etc are the derived classes .


Fig. INHERITANCE

3) Polymorphism: 

Polymorphism is the ability to take more than one form.

For example Consider a human being. Every human being has some roles to play. If its a male then he may be a son, husband, a father, an employee. If its female then she may be a daughter, a sister, a wife,a mother, an employee. So its the ability of a human being to take more than one role, and thats what we call Polymorphism in programming terminology.

Another example in terms of programming is addition operator. The + operator can be used for adding numbers and same operator can be used to concate two strings.


Fig. POLYMORPHISM

4) Encapsulation: 

It means wrapping up of data into single entity (class).

Example: We all have taken some kind of capsule at least once in a life. This capsule is nothing but the encapsulation. That capsule may have various chemicals but they all are wrapped together in a single entity called Capsule.

Another example is any car. The car has many parts like wheels,stearing, seats etc. but they all are bounded together to make a single car.

            

Fig. ENCAPSULATION





Share:

Friday, 15 July 2016

Objective-C: A Brief History

I think before starting learning about coding in Objective-C, we should have some rough idea about its background. So here is brief history of Objective-C.

The Objective-C programming language has had a humble history. Created by Brad Cox in the early 1980s as an extension of the venerated C, pioneered a decade earlier by Dennis Ritchie, the language was based on another called SmallTalk-80.
NeXT Software licensed the language in the 1988, and developed a code library called NeXTSTEP.
When Apple Computer acquired NeXT in 1996, the NeXTSTEP code library was built into the core of Apple’s operating system, Mac OS X. NeXTSTEP provided Apple with a modern OS foundation, which Apple could not produce on its own.
The iPhone’s operating system, currently dubbed iOS, is based off of a reduced version of OS X. Therefore, iOS inherits most of the NeXTSTEP code library, along with extensive modernisation and optimizations . Because NeXTSTEP was built from Objective-C, iOS mirrors the language choice. This made it easy for OS X developers to begin creating apps for the iPhone and iPod Touch.
Apple added a number of features to the Objective-C language, extending its functionality to parallel that of other languages that were beginning to arise. This major update was labeled Objective-C 2.0, and remains the language of choice for both OS X and iOS.
Objective-C is the native programming language for Apple’s iOS and OS X operating systems. It’s a compiled, general-purpose language capable of building everything from command line utilities to animated GUIs to domain-specific libraries. It also provides many tools for maintaining large, scalable frameworks.
                               
                           Types of programs written in Objective-C

Like C++, Objective-C was designed to add object-oriented features to C, but the two languages accomplished this using fundamentally distinct philosophies. Objective-C is decidedly more dynamic, deferring most of its decisions to run-time rather than compile-time. This is reflected in many of the design patterns underlying iOS and OS X development.
Share:

Thursday, 14 July 2016

Why to choose iOS developer as a career option..??


Hi Friends...,

It is my common observation about all students , that they are confused about selecting technology for career option. I too have faced the same during my job searching mission. Choosing right technology will definitely lead any developer to the right career path. While choosing technology we must be aware about some recent technologies in market. I have also faced the same problem. So this post is just to explain why you should opt for mobile development,more specifically iOS Development as your career option.  
             

WHY TO CHOOSE MOBILE DEVELOPMENT ?

Mobile is becoming a more and more significant part of life around the world. People are not only reliant on mobile phones now but they are constantly finding new ways to use them to enhance their daily lives; whether to improve their productivity at work or simply ordering their groceries. This technological growth is comparable to the popularity of the internet in its early years and is continuing at a quickening pace. As perhaps one of the first graduates of 'the mobile generation', who have grown up with mobile phones and use them as our primary means of communication, it is exciting to be right at the cutting edge of development in an industry that is in an evolutionary phase. It is a particularly exciting time for app developers, with more device functionality appearing every week such as GPS, video conferencing and audio streams in mobile format. This has empowered developers to create more diverse apps, which are applicable and relevant in all walks of life. 


Mobile app development is a hot skill. With more and more people opting for it, there is a dire need to choose the most in-demand mobile technology. Looking at the popularity and demand for Apple’s iPhone, iPad and iPod, it is safe to say that a career in iOS Development is a good bet. Experienced as well as entry-level professionals are entering the world of iOS Development as there are immense job opportunities that provide good pay package and even better career growth. A new survey of mobile app developers by VisionMobile also shows that iOS is the right technology to spend your time and money on.
The most popular operating systems are Android, iOS, and Windows. Currently, iOS and Android have taken over the majority of the mobile industry. According to recent stats, the two platforms account for around 96.7% of the entire market. 
With such huge audiences, iOS and Android offer plenty of opportunities for those who want to pursue a professional career in either OS, each with its own pros and cons for developers. Some mobile developers eventually strive to learn both operating systems to diversify their skill sets, but for beginner mobile developers, it’s best to choose the OS you’ll want to learn first and go from there. 

A new survey of mobile app developers by VisionMobile also shows that iOS is the right technology to spend your time and money on.

Need more reasons to kick start your iOS development career? Read on to find out…

Demand for iOS Skills:

The world has an insatiable appetite for new and better apps. Developers have numerous chances to exhibit their skill by developing interesting and innovative apps that run on iOS. With the growing popularity of iPhones, iPads and iPods and the appetite for new apps, we can expect a steady demand for iOS developers who can work some magic when it comes to developing apps.

The graph above from Indeed, a popular job portal illustrates the demand for this skill. If that is not convincing, here are some predictions of the ios market and the job demand by Joe Conway, Founder of Stable / Kernel, and author of ‘iOS Programming: The Big Nerd Ranch Guide’.
According to Joe, the demand for iOS Developers will remain high through 2015. He believes that this huge demand is due to the fact that skilled professionals are essential for maintaining and improving existing applications. These applications must be kept up-to-date with the release of new devices and versions of the iOS operating system, and also must compete with similar applications. He also concludes that there will be a dearth of professionals with the ability to develop native applications for iOS, this year. The existing shortage is mainly due to the soaring demand for new apps, as mentioned above.
Huo Ju, OS X and iOS Developer, mentions on Quora that the growing number of iOS devices shipped, number of start-ups focusing on mobile apps and the number of them wanting to develop their own iOS app, has resulted in a phenomenal need for the iOS professionals.

Home automation and Health are the two industries that are witnessing a lot of demand. Other industries like Travel, Transportation, Retail, Insurance, Banking and Financial Markets, Energy and Utilities, Telco and Law Enforcement are just some of the sectors that require iOS Developers.

Bigger remuneration for iOS professionals:

With the demand for this hot skill comes a handsome remuneration. According to Indeed, a popular job portal,  the average salary for iOS professionals is 68% higher than the average salary for other job postings. Indeed reports that the iOS professionals draw about 98,000 USD per annum.
This remuneration is not a short stint as the the salary trend by Indeed gives optimistic indication that this trend is expected to continue.
And Mondo, a company that recruits and places technology workers, reports that iOS Developers’ salary ranges from 105,000 to 155,000 USD per annum.

iOS related job titles and their salaries:
LinkedIn examined over 259,000,000 profiles in its database and concluded that the top position is occupied by iOS Developer job title. There are adequate job titles other than ‘iOS Developer’ for iOS professionals. Here are some of them and their corresponding salaries.


Source: Indeed.com
Now that you know about the demand for iOS skill, the salary and the different job titles, it is time to know what an iOS developer actually does and what skills are required to become one, be it a fresher or an experienced professional.

Job Responsibilities of an iOS Developer?

iOS Developers are responsible for building intuitive and eye-catching apps for mobile devices powered by Apple’s iOS operating system. In many ways, iOS Developers significantly contribute to a brand, as badly designed apps can result in negative opinion of the company. iOS Developers are expected to work in a diverse team comprising of managers, designers and other iOS Developers. Some of other job responsibilities of an iOS Developer are:
  • Design and build advanced native iOS apps on iOS platform
  • Work with cross-functional teams to define, design, and ship new features.
  • Unit-test code for sturdiness, including edge cases, usability, and general reliability.
  • Identify and correct bottlenecks and fix bugs
  • Continuously discover, evaluate, and implement new technologies to maximize development efficiency.
  • Help maintain code quality, organization, and automatization
  • Build sophisticated multi-threaded apps.
Tips for aspiring iOS professionals:
For those with little or no experience in programming, starting a career in iOS development can be arduous. Here are some tips to get you started:
  • Learn iOS development – There are numerous online resources and online courses that can assist you in your learning.
  • Start making apps right away – The best way to practice what you learnt is by developing applications. Start developing simple apps and make them available for free or at a low cost to the public so that you can get reviews and feedback. This will help you develop better ones in the future or further improve the existing ones.
  • Utilize any opportunity to create apps – You can improve your reputation by developing apps for small organizations at a low cost or for free. This will get you noticed for your skills.

Essential skills for an iOS Developer

According to Joe Conway, Founder of Stable / Kernel and author of ‘iOS Programming: The Big Nerd Ranch Guide’, a few of the must-have skills that will help you excel in your iOS development career are:
  • Ability to develop native, structurally sound software for iOS and Mac OS X platforms.
  • Keeping up with current UX/UI trends and remaining up to date on new functionality exposed through Apple’s SDKs.
  • Ability to utilize project management software, version control systems and develop automated testing and deployment strategies.
In order to start a career in iOS development, you will also require the following.
  • An Apple computer –  A advanced one would be better as you require good speed and memory when you’re developing and testing your apps.
  • iPhone /iPad /iPod – If possible buy one of each as you will need to test your app on different iOS platforms.
  • Become a member of the iOS Developer Program – You need to become a member to access all the developer tools made by Apple.

What you need to learn:

  • Objective C – iOS apps are created in this language, so having a strong foundation in it is absolutely essential.
  • iOS – Within iOS there are a host of frameworks and tools like adding text and images, building views, and handling user interactions, that a developer must know.
  • Swift – Swift is Apple’s programming language for iOS Apps. Learning the fundamentals of programming is the foundation for building apps.
  • XCode – XCode is the development studio for creating Apple-based programs and apps. It’s free to download and can be very helpful if you become proficient in it.
  • Interface Builder – It is a great tool by Apple that lets you create smart and eye-catching user interfaces via drag and drop.
  • Version Control – Learning to use a versioning system for code is an essential skill for any developer.
  • Frameworks – Being familiar with important frameworks makes the life of an iOS Developer fairly easier as it allows you to reuse code written by other developers in your apps.

Conclusion:

There is a lot of demand for iOS Developers today. It’s a reality that hot jobs require even hotter skills in order to land a drool-worthy position. It becomes imperative to determine where to invest your time and energy for growth as a developer. And investing your time and resources in learning iOS development is the best step forward for a lucrative career.

Share: