SlideShare a Scribd company logo
Objective-c Tricks
1
2 0 1 4 – Jan
B y : H o s s a m G h a r e e b
2
Use Literals
 The following is the old way of writing
code:
3
The same code can be written
as follows:
Subscripting
 You can use subscripting to access the
values inside dictionaries and arrays. This
is how the syntax looks:
4
Classes And Selectors From
Strings
 We can dynamically generate classes and
selectors from strings, We do this by using
the NSClassFromString and
NSSelectorFromString functions:
 NSClassFromString will return nil if there isn't a class
in the runtime that matches the string
5
 We can also decide in run time which selector to be called
based on input:
* Required 6
Method Swizzling
 Methods are made up of two components. The selector, which is an
identifier for a method, and the IMP, which is the actual implementation
that is run. One of the key things about this separation is that a selector
and IMP link can be changed. One IMP can have multiple selectors
pointing to it.
 Subclassing -> This allows you to override a method and call the original
implementation, but it means that you have to use instances of this
subclass.
 Category -> you cannot call the original implementation if you override
a method.
 Swizzling -> You can override a method without subclassing AND call
the original implementation
* Required 7
Example
 make a UINavigationBar green
 this will change all navigation bars in the app to
green, but if I used UIImagePickerController it will
be changed too!!!. We have to find new way for
that >>>>> Method Swizzling
8
Method Swizzling Cont.
 Method swizzling, in short, is switching methods at runtime. So
you can say for UINavigationBar don’t use the
standard drawRect:, but instead swap it with a different one
* Required 9
 Here is the swizzling:
10
Another problem solved by Swizzling
 measure how long the synchronize takes in
NSUserDefaults
* Required 11
Cont.
12
Example
 Borders around all UIViews
 initWithFrame: get a red border, views
that were unarchived (for example as
part of XIBs) get a blue border.
13
Surprise 
the status bar at the top of
an iOS app is drawn by
the app itself
14
How to do that ?
* Required 15
Cont.
* Required 16
Other tricks
 objc_msgSend()
This function takes a target, a selector and
a list of arguments
17
CGRect Tricks
 Shrink CGRect:
 Different insets for each edge:
using UIEdgeInsets(top, left, bottom, right)
18
Cont.
 CGRectUnion is UIScrollView’s best friend:
if you want use UIScrollView with bunch of
subviews, so you have to know only the top-left
and bottom-right views:
19
Cont.
 Dictionary Representation (to store in in plist on disk):
20
Print CGRect values :
Cont.
 Storing it in Obj-C Storage Classes
21
Thank you
Any Questions?
22

More Related Content

Viewers also liked

Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
Matteo Battaglio
 
Hackatron - UIKit Dynamics
Hackatron - UIKit DynamicsHackatron - UIKit Dynamics
Hackatron - UIKit DynamicsRenzo G. Pretto
 
iOS中Lua脚本的应用
iOS中Lua脚本的应用iOS中Lua脚本的应用
iOS中Lua脚本的应用
Proteas Wang
 
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en增强 杜
 
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例Justin Lee
 
20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介Justin Lee
 
Android Application Development at JFokus 2011
Android Application Development at JFokus 2011Android Application Development at JFokus 2011
Android Application Development at JFokus 2011Anders Göransson
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatchcqtt191
 
iOS Multithreading
iOS MultithreadingiOS Multithreading
iOS MultithreadingRicha Jain
 
CS193P Lecture 5 View Animation
CS193P Lecture 5 View AnimationCS193P Lecture 5 View Animation
CS193P Lecture 5 View Animation
onoaonoa
 
iOS Application Lifecycle
iOS Application LifecycleiOS Application Lifecycle
iOS Application LifecycleSiva Prasad K V
 
AnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and TricksAnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and Tricks
jimi-c
 
iOS Developer Interview Questions
iOS Developer Interview QuestionsiOS Developer Interview Questions
iOS Developer Interview Questions
Clark Davidson
 
Multithreading and Parallelism on iOS [MobOS 2013]
 Multithreading and Parallelism on iOS [MobOS 2013] Multithreading and Parallelism on iOS [MobOS 2013]
Multithreading and Parallelism on iOS [MobOS 2013]Kuba Břečka
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCD
rsebbe
 
Extending Titanium with native iOS and Android modules
Extending Titanium with native iOS and Android modules Extending Titanium with native iOS and Android modules
Extending Titanium with native iOS and Android modules
omorandi
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
Vineet Kumar Saini
 

Viewers also liked (19)

Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
 
Hackatron - UIKit Dynamics
Hackatron - UIKit DynamicsHackatron - UIKit Dynamics
Hackatron - UIKit Dynamics
 
iOS中Lua脚本的应用
iOS中Lua脚本的应用iOS中Lua脚本的应用
iOS中Lua脚本的应用
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
 
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
 
20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介
 
Android Application Development at JFokus 2011
Android Application Development at JFokus 2011Android Application Development at JFokus 2011
Android Application Development at JFokus 2011
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatch
 
iOS Multithreading
iOS MultithreadingiOS Multithreading
iOS Multithreading
 
CS193P Lecture 5 View Animation
CS193P Lecture 5 View AnimationCS193P Lecture 5 View Animation
CS193P Lecture 5 View Animation
 
iOS Application Lifecycle
iOS Application LifecycleiOS Application Lifecycle
iOS Application Lifecycle
 
AnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and TricksAnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and Tricks
 
iOS Developer Interview Questions
iOS Developer Interview QuestionsiOS Developer Interview Questions
iOS Developer Interview Questions
 
Multithreading and Parallelism on iOS [MobOS 2013]
 Multithreading and Parallelism on iOS [MobOS 2013] Multithreading and Parallelism on iOS [MobOS 2013]
Multithreading and Parallelism on iOS [MobOS 2013]
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCD
 
Extending Titanium with native iOS and Android modules
Extending Titanium with native iOS and Android modules Extending Titanium with native iOS and Android modules
Extending Titanium with native iOS and Android modules
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 

Similar to Objective C Tricks

Abstraction
Abstraction Abstraction
Abstraction
KrishnaChauhan499414
 
Abstraction
AbstractionAbstraction
Javascript Deofuscation A manual Approach
Javascript Deofuscation A manual ApproachJavascript Deofuscation A manual Approach
Javascript Deofuscation A manual Approach
Gregory Hanis
 
Cobol interview-questions
Cobol interview-questionsCobol interview-questions
Cobol interview-questions
SreenivasaRao Bathula
 
Instrumentation and measurements
Instrumentation and measurementsInstrumentation and measurements
Instrumentation and measurements
Tuba Tanveer
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx java
CongTrung Vnit
 
Apply Template Method Pattern in Report Implementation
Apply Template Method Pattern in Report ImplementationApply Template Method Pattern in Report Implementation
Apply Template Method Pattern in Report ImplementationGuo Albert
 
Interface and abstraction
Interface and abstractionInterface and abstraction
Interface and abstractionRaghav Chhabra
 
Inline function
Inline functionInline function
Inline functionTech_MX
 
MVC
MVCMVC
DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...
DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...
DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...
Felipe Prado
 
Objective c slide I
Objective c slide IObjective c slide I
Objective c slide I
Diksha Bhargava
 
maXbox Starter 43 Work with Code Metrics ISO Standard
maXbox Starter 43 Work with Code Metrics ISO StandardmaXbox Starter 43 Work with Code Metrics ISO Standard
maXbox Starter 43 Work with Code Metrics ISO Standard
Max Kleiner
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLAkhil Mittal
 
CIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in JavaCIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in Java
Hamad Odhabi
 
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docxSMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
pbilly1
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2
Knoldus Inc.
 
Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#
Umar Farooq
 

Similar to Objective C Tricks (20)

Abstraction
Abstraction Abstraction
Abstraction
 
Abstraction
AbstractionAbstraction
Abstraction
 
Javascript Deofuscation A manual Approach
Javascript Deofuscation A manual ApproachJavascript Deofuscation A manual Approach
Javascript Deofuscation A manual Approach
 
Cobol interview-questions
Cobol interview-questionsCobol interview-questions
Cobol interview-questions
 
Instrumentation and measurements
Instrumentation and measurementsInstrumentation and measurements
Instrumentation and measurements
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx java
 
Apply Template Method Pattern in Report Implementation
Apply Template Method Pattern in Report ImplementationApply Template Method Pattern in Report Implementation
Apply Template Method Pattern in Report Implementation
 
Interface and abstraction
Interface and abstractionInterface and abstraction
Interface and abstraction
 
Inline function
Inline functionInline function
Inline function
 
C# features
C# featuresC# features
C# features
 
MVC
MVCMVC
MVC
 
DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...
DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...
DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...
 
Objective c slide I
Objective c slide IObjective c slide I
Objective c slide I
 
Designing Better API
Designing Better APIDesigning Better API
Designing Better API
 
maXbox Starter 43 Work with Code Metrics ISO Standard
maXbox Starter 43 Work with Code Metrics ISO StandardmaXbox Starter 43 Work with Code Metrics ISO Standard
maXbox Starter 43 Work with Code Metrics ISO Standard
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQL
 
CIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in JavaCIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in Java
 
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docxSMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2
 
Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#
 

More from Inova LLC

MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
Inova LLC
 
Activities vs fragment
Activities vs fragmentActivities vs fragment
Activities vs fragment
Inova LLC
 
Benefits of idea treasury
Benefits of idea treasuryBenefits of idea treasury
Benefits of idea treasury
Inova LLC
 
Advertising
Advertising Advertising
Advertising
Inova LLC
 
Market research
Market researchMarket research
Market research
Inova LLC
 
Disc Personality Type
Disc Personality TypeDisc Personality Type
Disc Personality Type
Inova LLC
 
UI vs UX workshop
UI vs UX workshopUI vs UX workshop
UI vs UX workshop
Inova LLC
 
Positive thinking
Positive thinkingPositive thinking
Positive thinking
Inova LLC
 
Sketch app interface
Sketch app interfaceSketch app interface
Sketch app interface
Inova LLC
 
Inova
InovaInova
Inova
Inova LLC
 
Inova
InovaInova
Inova
Inova LLC
 
CSED 2018 Orientation
CSED 2018 OrientationCSED 2018 Orientation
CSED 2018 Orientation
Inova LLC
 
Mind map Introduction
Mind map IntroductionMind map Introduction
Mind map Introduction
Inova LLC
 
Agile scheduling
Agile schedulingAgile scheduling
Agile scheduling
Inova LLC
 
Business plan
Business planBusiness plan
Business plan
Inova LLC
 
Introduction to Sencha touch
Introduction to Sencha touchIntroduction to Sencha touch
Introduction to Sencha touch
Inova LLC
 
Introduction to Agile
Introduction to AgileIntroduction to Agile
Introduction to Agile
Inova LLC
 
Internet Presence
Internet PresenceInternet Presence
Internet Presence
Inova LLC
 
Agile Planning for value
Agile Planning for valueAgile Planning for value
Agile Planning for value
Inova LLC
 
Agile estimate size
Agile estimate sizeAgile estimate size
Agile estimate size
Inova LLC
 

More from Inova LLC (20)

MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
 
Activities vs fragment
Activities vs fragmentActivities vs fragment
Activities vs fragment
 
Benefits of idea treasury
Benefits of idea treasuryBenefits of idea treasury
Benefits of idea treasury
 
Advertising
Advertising Advertising
Advertising
 
Market research
Market researchMarket research
Market research
 
Disc Personality Type
Disc Personality TypeDisc Personality Type
Disc Personality Type
 
UI vs UX workshop
UI vs UX workshopUI vs UX workshop
UI vs UX workshop
 
Positive thinking
Positive thinkingPositive thinking
Positive thinking
 
Sketch app interface
Sketch app interfaceSketch app interface
Sketch app interface
 
Inova
InovaInova
Inova
 
Inova
InovaInova
Inova
 
CSED 2018 Orientation
CSED 2018 OrientationCSED 2018 Orientation
CSED 2018 Orientation
 
Mind map Introduction
Mind map IntroductionMind map Introduction
Mind map Introduction
 
Agile scheduling
Agile schedulingAgile scheduling
Agile scheduling
 
Business plan
Business planBusiness plan
Business plan
 
Introduction to Sencha touch
Introduction to Sencha touchIntroduction to Sencha touch
Introduction to Sencha touch
 
Introduction to Agile
Introduction to AgileIntroduction to Agile
Introduction to Agile
 
Internet Presence
Internet PresenceInternet Presence
Internet Presence
 
Agile Planning for value
Agile Planning for valueAgile Planning for value
Agile Planning for value
 
Agile estimate size
Agile estimate sizeAgile estimate size
Agile estimate size
 

Recently uploaded

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 

Recently uploaded (20)

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 

Objective C Tricks

  • 1. Objective-c Tricks 1 2 0 1 4 – Jan B y : H o s s a m G h a r e e b
  • 2. 2 Use Literals  The following is the old way of writing code:
  • 3. 3 The same code can be written as follows:
  • 4. Subscripting  You can use subscripting to access the values inside dictionaries and arrays. This is how the syntax looks: 4
  • 5. Classes And Selectors From Strings  We can dynamically generate classes and selectors from strings, We do this by using the NSClassFromString and NSSelectorFromString functions:  NSClassFromString will return nil if there isn't a class in the runtime that matches the string 5
  • 6.  We can also decide in run time which selector to be called based on input: * Required 6
  • 7. Method Swizzling  Methods are made up of two components. The selector, which is an identifier for a method, and the IMP, which is the actual implementation that is run. One of the key things about this separation is that a selector and IMP link can be changed. One IMP can have multiple selectors pointing to it.  Subclassing -> This allows you to override a method and call the original implementation, but it means that you have to use instances of this subclass.  Category -> you cannot call the original implementation if you override a method.  Swizzling -> You can override a method without subclassing AND call the original implementation * Required 7
  • 8. Example  make a UINavigationBar green  this will change all navigation bars in the app to green, but if I used UIImagePickerController it will be changed too!!!. We have to find new way for that >>>>> Method Swizzling 8
  • 9. Method Swizzling Cont.  Method swizzling, in short, is switching methods at runtime. So you can say for UINavigationBar don’t use the standard drawRect:, but instead swap it with a different one * Required 9
  • 10.  Here is the swizzling: 10
  • 11. Another problem solved by Swizzling  measure how long the synchronize takes in NSUserDefaults * Required 11
  • 13. Example  Borders around all UIViews  initWithFrame: get a red border, views that were unarchived (for example as part of XIBs) get a blue border. 13
  • 14. Surprise  the status bar at the top of an iOS app is drawn by the app itself 14
  • 15. How to do that ? * Required 15
  • 17. Other tricks  objc_msgSend() This function takes a target, a selector and a list of arguments 17
  • 18. CGRect Tricks  Shrink CGRect:  Different insets for each edge: using UIEdgeInsets(top, left, bottom, right) 18
  • 19. Cont.  CGRectUnion is UIScrollView’s best friend: if you want use UIScrollView with bunch of subviews, so you have to know only the top-left and bottom-right views: 19
  • 20. Cont.  Dictionary Representation (to store in in plist on disk): 20 Print CGRect values :
  • 21. Cont.  Storing it in Obj-C Storage Classes 21