Objective-C: The Ultimate Guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Objective-C is a general-purpose, object-oriented programming language that extends the C programming language with Smalltalk-style messaging. While simultaneously developing for OS X and iOS, Objective-C's capabilities have been bolstered by the inclusion of a dynamic runtime and assistance for object-oriented programming. Objective-C: The Ultimate Guide walks developers and coders through a straightforward and practical method of learning the Objective-C programming language. This book discusses the basics in brief, and then moves on to more advanced and detailed exercises to help readers quickly gain the required knowledge. The focus in this book remains on writing optimized and well-structured code in Objective-C. Key Features Follows a hands-on approach and offers practical lessons and tutorials related to Objective-C Discusses Objective-C using real world industry concepts Includes at-length discussion of Objective-C concepts to help build robust knowledge

Author(s): Sufyan bin Uzayr
Publisher: CRC Press
Year: 2023

Language: English
Pages: 340
City: Boca Raton

Cover
Half Title
Title Page
Copyright Page
Dedication
Contents
About the Author
Acknowledgments
CHAPTER 1: Crash Course in Objective-C
OBJECTIVE-C SPECIFICS
WHY OBJECTIVE-C?
DIFFERENTIATING OBJECTIVE-C VERSUS SWIFT
DIFFERENTIATING OBJECTIVE-C FROM C++
UPSIDES AND DOWNSIDES OF OBJECTIVE-C
Upsides
Downsides
FACTORS TO CONSIDER
OBJECTIVE-C OVERVIEW
FRAMEWORK FOR THE FOUNDATION
LEARNING OBJECTIVE-C
USING OBJECTIVE-C
SETUP OF THE OBJECTIVE-C ENVIRONMENT
LOCAL ENVIRONMENT CONFIGURATION
EDITOR OF TEXT
GCC COMPILER
UNIX/LINUX INSTALLATION
MAC OS INSTALLATION
WINDOWS INSTALLATION
STRUCTURE OF THE OBJECTIVE-C PROGRAM
OBJECTIVE-C EXAMPLE OF HELLO EVERYONE
BASIC SYNTAX IN OBJECTIVE-C
OBJECTIVE-C TOKENS
SEMICOLONS;
COMMENTS
IDENTIFIERS
KEYWORDS
WHITESPACE IN OBJECTIVE-C
DATA TYPES IN OBJECTIVE-C
TYPES OF INTEGERS
TYPES OF FLOATING-POINT
VOID TYPE
VARIABLES IN OBJECTIVE-C
OBJECTIVE-C VARIABLE DEFINITION
OBJECTIVE-C VARIABLE DECLARATION
OBJECTIVE-C lvalues AND rvalues
CONSTANTS IN OBJECTIVE-C
INTEGER LITERALS
FLOATING-POINT LITERALS
CHARACTER CONSTANTS
STRING LITERALS
CONSTANT DEFINITION
#define Preprocessor
const Keyword
OPERATORS IN OBJECTIVE-C
ARITHMETIC OPERATORS IN OBJECTIVE-C
RELATIONAL OPERATORS
LOGICAL OPERATORS IN OBJECTIVE-C
BITWISE OPERATORS
ASSIGNMENT OPERATORS
MISC OPERATORS ↦ SIZEOF & TERNARY
OPERATORS’ PRECEDENCE IN THE OBJECTIVE-C
LOOPS IN OBJECTIVE-C
CONTROL STATEMENTS FOR LOOPS
INFINITE LOOP
DECISION MAKING IN OBJECTIVE-C
THE ? : OPERATOR
FUNCTIONS IN OBJECTIVE-C
CREATING A METHOD
DECLARATIONS OF METHOD
CALLING A METHOD
FUNCTION ARGUMENTS
BLOCKS IN OBJECTIVE-C
Simple Block Declaration Syntax
Implementation of a Simple Block
BLOCKS TAKE ARGUMENTS AND RETURN VALUES
BLOCKS USING THE TYPE DEFINITIONS
NUMBERS IN OBJECTIVE-C
ARRAYS IN OBJECTIVE-C
DECLARING ARRAYS
ARRAYS INITIALIZATION
ACCESSING ARRAY ELEMENTS
ARRAYS IN OBJECTIVE-C IN DEPTH
POINTERS IN OBJECTIVE-C
WHAT EXACTLY ARE POINTERS IN OBJECTIVE-C?
How Do Pointers Work?
OBJECTIVE-C NULL POINTERS
DETAILS ABOUT OBJECTIVE-C POINTERS
STRINGS IN OBJECTIVE-C
STRUCTURES IN OBJECTIVE-C
CREATING A STRUCTURE
ACCESS TO STRUCTURE MEMBERS
FUNCTION ARGUMENTS AS STRUCTURES
POINTERS TO STRUCTURES
BIT FIELDS
PREPROCESSORS IN OBJECTIVE-C
EXAMPLES OF PREPROCESSORS
PREDEFINED MACROS
OPERATORS OF PREPROCESSORS
Macro Continuation (\)
Stringize (#)
Token Pasting (##)
defined() Operator
PARAMETERIZED MACROS
Typedef IN OBJECTIVE-C
typedef vs #define
TYPE CASTING IN OBJECTIVE-C
INTEGER PROMOTION
USUAL ARITHMETIC CONVERSION
LOG HANDLING IN OBJECTIVE-C
NSLog METHOD
DISABLING LOGS IN THE LIVE Apps
ERROR HANDLING IN OBJECTIVE-C
NSError
COMMAND-LINE ARGUMENTS
BIBLIOGRAPHY
CHAPTER 2: OOP in Objective-C
OBJECT-ORIENTED PROGRAMMING
OPERATIONS AND DATA
IMPLEMENTATION AND INTERFACE
THE OBJECT MODEL
THE METAPHOR OF MESSAGING
CHARACTERISTIC OF OBJECTIVE-C
DEFINITIONS OF OBJECTIVE-C CLASSES
ALLOCATING AND INITIALIZING OBJECTIVE-C OBJECTS
ACCESSING DATA MEMBERS
Properties
Modularity
Reusability
INHERITANCE IN OBJECTIVE-C
BASE AND DERIVED CLASSES
ACCESS THE CONTROL AND INHERITANCE
Hierarchies of Class
Definitions of Subclass
DYNAMISM
POLYMORPHISM IN OBJECTIVE-C
DATA ENCAPSULATION IN OBJECTIVE-C
EXAMPLE OF DATA ENCAPSULATION
CREATING A STRATEGY
CATEGORIES IN OBJECTIVE-C
CATEGORY CHARACTERISTICS
POSING IN OBJECTIVE-C
POSING RESTRICTIONS
EXTENSIONS IN OBJECTIVE-C
EXTENSIONS’ CHARACTERISTICS
Example of Extensions
PROTOCOLS IN OBJECTIVE-C
DYNAMIC BINDING IN OBJECTIVE-C
COMPOSITE OBJECTS IN OBJECTIVE-C
CLASS CLUSTERS
WHAT EXACTLY IS A COMPOSITE OBJECT?
An Example of a Composite Object
FOUNDATION FRAMEWORK IN OBJECTIVE-C
Functionality-Based Foundation Classes
FAST ENUMERATION IN OBJECTIVE-C
COLLECTIONS IN THE OBJECTIVE-C
MEMORY MANAGEMENT IN OBJECTIVE-C
“MANUAL RETAIN-RELEASE” OR MRR
Basic MRR Rules
“AUTOMATIC REFERENCE COUNTING” OR ARC
BIBLIOGRAPHY
CHAPTER 3: Interface and API
iOS IN OBJECTIVE-C
IMPLEMENTATION AND INTERFACE
OBJECT CREATION
METHODS
Class Methods
Instance Methods
IMPORTANT OBJECTIVE-C DATA TYPES
Printing Logs
CONTROL STRUCTURES
PROPERTIES
Properties of Accessing
CATEGORIES
Arrays
Dictionary
ENVIRONMENT SETUP
Installation of Xcode
INTERFACE BUILDER
SIMULATOR FOR iOS
FIRST iPHONE APPLICATION
FIRST iOS APPLICATION’S CODE
AppDelegate.h
AppDelegate.m
ViewController.h
ViewController.m
ACTIONS AND OUTLETS IN iOS
DELEGATES IN iOS
How to Create a Delegate
UI ELEMENTS
What Are UI Elements?
How Do We Insert UI Elements?
Our Focus
Our Strategy
LIST OF UI ELEMENTS
ACCELEROMETER IN iOS
UNIVERSAL APPLICATIONS IN iOS
CAMERA MANAGEMENT IN iOS
LOCATION HANDLING IN iOS
SQLite DATABASE IN iOS
SENDING EMAIL ON iOS
AUDIO AND VIDEO IN iOS
FILE HANDLING IN iOS
METHODS FOR FILE HANDLING
Check to See If a File in Objective-C Exists at a Given Path
Comparing the Contents of Two Files
Check to See If It Is Writable, Readable, and Executable
Move File
Copy File
Remove File
Read File
Write File
ACCESSING MAPS ON iOS
IN-APP PURCHASE IN iOS
iAd INTEGRATION IN iOS
GameKit IN iOS
STORYBOARDS IN iOS
AUTO LAYOUTS IN iOS
Aim of Our Example
Our Strategy
The Involved Steps
TWITTER AND FACEBOOK ON iOS
MEMORY MANAGEMENT IN iOS
MEMORY MANAGEMENT CHALLENGES
RULES FOR MEMORY MANAGEMENT
DEALING WITH MEMORY IN ARC
MEMORY MANAGEMENT TOOLS
ANALYTICAL METHODS FOR MEMORY ALLOCATIONS
APPLICATION DEBUGGING IN iOS
CHOOSING A DEBUGGER
HOW TO LOCATE CODING ERRORS
SET BREAKPOINTS
BREAKPOINT EXCEPTION
IN AN iOS App, WE MAY USE GOOGLE APIs
BIBLIOGRAPHY
CHAPTER 4: Functional Programming
WHY OBJECT-FUNCTIONAL PROGRAMMING?
OBJECTIVE-C FUNCTIONAL PROGRAMMING
On Functional Programming
On the ObjC Runtime
On Objective-C and Language Design
WRITE OBJECTIVE-C CODE
CLASSES AND OBJECTS
METHODS AND COMMUNICATION
CLASS METHODS
Properties and Accessor Methods Are Declared
BLOCKS
PROTOCOLS AND CATEGORIES
Types and Coding Strategies Are Defined
CREATE THE VIDEO App
Set the App’s Audio Behavior
Build View Controller Class Declaration
Import the Brightcove Player SDK Header File into the Program
Look at the Code
Construct the View Controller Implementation in Objective-C
Customize the Project to Reflect Our Values
Declare Properties
DEFINE INITIALIZATION METHOD
Setup Player
Configure Player
Use the Brightcove Library to Request Material
Look at the Code
BIBLIOGRAPHY
CHAPTER 5: Code Management
WHY MUST WE PERFORM THIS?
ANATOMY OF A FRAMEWORK
STATIC AND DYNAMIC FRAMEWORKS
ARCHITECTURES AND SLICING OF PROCESSORS
DEVELOPING A DYNAMIC STRUCTURE
SETTING UP OUR PROJECT
DEVELOPING OUR CODE
ACCESS CONTROL
UMBRELLA HEADER
UNIVERSAL SUPPORT
UTILIZING OUR DYNAMIC FRAMEWORK
DEVELOPING A STATIC FRAMEWORK
SETTING UP OUR PROJECT
DEVELOPING OUR CODE
ACCESS CONTROL
UMBRELLA HEADER
PACKAGING
MODIFY BUILD SETTINGS TO SUPPORT STATIC FRAMEWORKS
MODULE SUPPORT
CREATING THE BUNDLE STRUCTURE
UNIVERSAL SUPPORT
UTILIZING OUR STATIC FRAMEWORK
RECOMMENDATIONS
COMPILING AND CONSTRUCTING THE FRAMEWORK
UPLOADING AN APPLICATION’S FRAMEWORK TO THE APP STORE
MEMORY MANAGEMENT IN OBJECTIVE-C
“MANUAL RETAIN-RELEASE” OR MRR
Basic MRR Rules
“AUTOMATIC REFERENCE COUNTING” OR ARC
Effective Procedures Prevent Memory-Related Issues
DEBUG MEMORY ISSUES USING ANALYSIS TOOLS
THE GOAL OF MEMORY MANAGEMENT
Avoid Crashing
Strong vs Weak
Atomic and Nonatomic
DESIGN PATTERNS IN iOS
FAÇADE
When to Use the Facade Pattern?
An Illustration of Facade Design Pattern
DECORATOR
When Should We Use a Decorator Pattern?
Example of Decorator Style Design
MEMENTO
ADAPTER
When to Use an Adapter?
Illustration of Adapter Pattern
OBSERVER
When Should We Use a Decorator Pattern?
Example of Decorator Style Design
STRATEGY
FACTORY
COMMAND
COMPOSITE
ITERATOR
MEDIATOR
SINGLETON
When Should We Use the Singleton Design Pattern?
Illustration of Singleton Pattern
MVC
MVP
MVVM
Feature Assessment
VIPER
WHAT ARE THE ADVANTAGES OF EMPLOYING iOS DESIGN PATTERNS?
Prepared to Develop iOS Applications Using iOS Design Patterns
BIBLIOGRAPHY
CHAPTER 6: Code Optimization
OBJECTIVE-C CODE OPTIMIZATION AT COMPILE TIME
OBJECTIVE-C PIPELINE
SECURE CODE
Security Breach through HTTPS Response Cache
RESUME BACKGROUND DISCLOSURE OF SCREENSHOT DATA
SSL PINNING
BEST PRACTICES WITH OBJECTIVE-C CODING CONVENTION
Operators
Types
Methods
Pragma Mark and Implementation Organization
Control Structures
Switch
For
While
Import
Header Prefix
Properties
Private Methods and Properties
Extern, Const, and Static
Naming
Enums
HARDENING OF SYSTEMS
Hardening of Systems to Reduce the “Attack Surface”
Advantages of System Hardening
BIBLIOGRAPHY
APPRAISAL
OBJECTIVE-C CHEAT SHEET
INDEX