Lecture 28 29

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

INSTITUTE : UIE

DEPARTMENT : CSE
Bachelor of Engineering (Computer Science
& Engineering)
Mobile Application Development(20CST-355)

TOPIC OF PRESENTATION:
iOS: IOS Project, Debugging iOS Apps, Objective-C
Basics, Building the Derby App in IOS
Prepared by:
Parveen Kumar Saini(E13339)

DISCOVER . LEARN .
www.cuchd.in EMPOWER
Computer Science and Engineering Department
iOS: IOS Project, Debugging iOS Apps, Objective-C Basics, Building the
Derby App in IOS

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
What is iOS?
• iOS is an operating system – it’s a subset of Mac OS X.
• The iOS SDK is the software development kit that allows application programs
to utilize classes and frameworks provided by the SDK. This class will focus on
iOS SDK6.
• iOS is multitasking and runs on several different devices(iPhones, iPod
Touches, iPads, and Apple TVs).
• Apple provides an IDE called Xcode.
• Xcode is the IDE used by iOS (and OS X) developers.
• Xcode provides an interface to the compiler, editor, debugger, and code
profiling tools. PROF. ERWIN M. GLOBIO, MSIT

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
IOS Project
• Conventions
• Structure
• Project

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Naming conventions
• First establish a naming convention for all the things for file names, class
names, project names, images, etc.
• Use Pascal Case for files, folders and class start with a capital letter i.e.
Controllers, MyClass, BestAppEver, etc.
• Use Camel Case for methods, properties & variables start with a lowercase
letter i.e setFirstName:, userPassword, etc.  

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Coding conventions
• Choose your coding conventions & style
• there are ton of conventions out there
• K&R Style, or Allman Indent Style
http://en.wikipedia.org/wiki/Indent_style
• Also read Coding Guidelines for Cocoa by Apple
http://developer.apple.com/library/mac/#documentation/Cocoa/
Conceptual/CodingGuidelines/CodingGuidelines.html
• But most important, choose a convention and respect it the important thing is
always be consistent in your project

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Structure
• Create a specific workspace
don’t let Xcode do it for you
• Setting up projects with correct name and prefix
use simple word (only alphanumeric) and at least 3 chars for prefix
• Create a Build Automation to scripting common tasks
to compiling source code or to deploy artifacts with one command
• Create a README file with most important info
you can use markdown syntax or other markup language like that

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Structure
• Create a AdHoc and AppStore Build Configuration
So you can handle configuration for different destination
• Configure Build Settings to improve quality
i.e. you can enable Static Analyzer or Treat Warnings as Errors
• Manage third-part libraries with CocoaPods
it reduces headaches of storing/managing 3rd party libraries

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Project Name & Prefix
• Choose a simple Product Name
Only alphanumeric characters, avoid spaces
• Choose a right Class Prefix
At least 3 chars, use product name's acronym
• Choose your Personal Prefix
Use it in your Library Projects
• Use Automatic Reference Counting
If app targets iOS 5.0 or above

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Build Automation
• It’s the act of automating a wide variety of tasks
you can use build tools like Ant, Maven, Make , CMake or Rake
• At least you must automate Compiling and Deploying
compiling and deploying are the most common tasks for developer
• You can also automate Testing and Docs generation
they are useful to use in combination with a Continuous Integration
• You can also automate Static Code Analysis tools
for improving quality and reducing defects by inspecting C, C++ and
Objective-C code

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Folders
• Put things in the right place
...and everything makes sense, unfortunately, Xcode doesn’t help us
• Map all Xcode group folders to file system directories
Xcode group folder don’t represent physical folder
• Please remove Supporting Files group folder
Who wants “Supporting Files” anymore? 

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
My folders structure
• Application
specific app related stuff like AppDelegate, main.m, .pch etc
• Controllers
view (.xib) and view controller stuff put together (obviously)
• Library
specific application classes like helpers, base classes, services, etc

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
My folders structure
• Models
application domain models and entities, Core Data models too
• Resources
assets like images, fonts, sounds, videos, etc.
• Vendors
third part libraries and frameworks (not managed by CocoaPods)

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Project Structure in Depth
• When an iOS project is created within xCode, the IDE creates a set of files that are ready
to run. These files provide the basics of what is needed to get going with a new project.

• Main.m
As with any C program, the execution of Objective-C applications start from the main()
function, which is the main.m file.

• AppDelegate.m
The AppDelegae receives messages from the application object during the lifetime of
your application. The AppDelegate is called from the operating system, and contains
events such as the didFinishLaunchingWithOptions, which is an event that iOS would be
interested in knowing about.

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Project Structure in Depth
• MainStoryBoard.storyboard
This is where the user interface is created. In past versions of xCode/iOS the
user interface was stored within .xib (pronounced NIB) files. Although this
method is still supported, Storyboards are a great improvement over .xib fi les
for applications with complex navigation and many views.
• Supporting Files
The supporting files directory contains files such as the plist setting files
(which contain customizable application settings), as well as string resource
files that are used within your app.

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Debugging IOS App
• Modern-day IDEs provide a great deal of tooling that helps developers find issues in
their code before it reaches production.
• The iOS Simulator
• Developers use the iOS Simulator as their first way of finding issues with the code
they just created.
• The iOS Simulator enables developers to run their iOS applications on their Macs
without having to have a physical iOS device.
• The Simulator is a great tool for testing your apps quickly.
• The iOS Simulator is very quick to load, compared to other simulation tools for other
mobile platforms.
• The iOS Simulator is also a great tool for HTML/CSS experts to have installed as well
to test mobile webpages rendered within the mobile Safari web browser

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Debugging Code
• As with many modern-day IDEs, Apple and the xCode team have put a great
deal of time and effort into creating a set of tools to aid developers in their
quest for hunting bugs. Many tools to step through the code, view log
messages, as well as see the state of their variables.
• xCode provides tools for these features, and much more.
• The debugging tools within xCode are located at the bottom of the workspace
window. If you do not see the debugging tools, you can click View ➪ Debug
Area ➪ Show Debug Area from the xCode menu to make the debugging tools
visible.

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Debugging code
• Local Window
When the debug area is enabled, the local window shows you a list of all of
the variables that are currently within scope of your current breakpoint, and
enables you to view details about each variable.
• Breakpoints
You can set breakpoints by clicking on the “gutter” next to the line of code
where you would like the application to break. Breakpoints can be enabled
and disabled; disabled breakpoints have an opaque blue color, whereas active
breakpoints are a solid blue,

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Debugging code
• Output
The output section of the Debug Area gives important information about the execution of
the app, as well as displays any log messages you may add in your code
• Instruments
Suppose you’ve spent the last few weeks working nights to get a version of an iOS app
ready for release, but after you use your application for about 15 minutes, it stops for no
reason.
• You think it may be a memory leak of some kind, but are not completely sure because the
log messages were pretty cryptic. Instruments is the tool for you.
• Instruments can be found in the Developer ➪ Application directory. Tools within the
Instruments tool suite enable you to track down memory issues and help find slow-
running code. Instruments is one of our favorite tools found within xCode, because it helps
us find those hard-to-replicate issues.

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
What Is Objective C ?
• Objective-C is the primary programming language you use when writing
software for OS X and iOS.
• It’s a superset of the C programming language and provides object-oriented
capabilities and a dynamic runtime.
• Objective-C inherits the syntax, primitive types, and flow control statements
of C and adds syntax for defining classes and methods.
• Objective-C inherits the syntax, primitive types, and flow control statements
of C and adds syntax for defining classes and methods.

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Objective – C Characteristics
• The class is defined in two different sections namely @interface and
@implementation.
• Almost everything is in form of objects.
• Objects receive messages and objects are often referred as receivers.
• Objects contain instance variables.
• Objects and instance variables have scope.

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Language Concepts
• Fully supports object-oriented programming, including the four pillars of
object-oriented development:
• Encapsulation
• Data hiding
• Inheritance
• Polymorphism

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Classes
• The interface of Objective-C classes is defined in a header file for each interface.
Usually the filenames of the header match the class name. For example, you can
create a header file named dog.h:
@interface Dog : Animal {
// instance variables
}
// Method declarations
@end
You are telling the compiler that a new class named Dog, which is a subclass of animal,
is being declared. Any instance variables are declared between the curly brackets,
and methods are declared between the end of the curly bracket and the @end
keyword.

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Methods
• Methods can be declared as either instance methods or class methods.
• Instance methods are called by sending a message directly to the instance of
the class, which means you need to have your own instance of the class before
you can call these methods.
• Instance methods are prefi xed with a minus sign (-).
• The following is an example of the declaration for an instance method that
returns the name of the animal, and takes no parameters:
-(NSString) getNameOfAnimal;

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Objective-C Operators
• An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations.
• Objective-C language is rich in built-in operators and provides following
types of operators:
• Arithmetic Operators – (+, -, *, /, %, ++, --)
• Relational Operators – (=, !=, >, <, >=, <= )
• Logical Operators – (&&, ||, ! )
• Bitwise Operators – ( &, |, ^, <<, >>)
• Assignment Operators – (=, +=, -=, *=, /=, %=, >>=, <<=, &=, ^=, |= )
• Misc Operators – (sizeof, &, *, ?:)

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
Objective-C Loops
• A loop statement allows us to execute a statement or group of statements
multiple times and following is the general form of a loop statement in most
of the programming languages:
– while
– for
– do while
– nested loops Loop
• Control Statements:
– break statement
– control statement

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE)
THANK YOU

For queries
Email: parveen.e13339@cumail.in

www.cuchd.in Computer
University Science and
Institute Engineering Department
of Engineering (UIE) 27

You might also like