SlideShare a Scribd company logo
Developing Mobile
Application
Ios : session # 3
By : Amr Elghadban
AMR
ELGHADBAN
ABOUT ME
———————————
SOFTWARE ENGINEER
FCI - HELWAN 2010
ITI INTAKE 32
WORKED BEFORE IN
- Tawasol IT
- Etisalat Masr
- NTG Clarity
property
@property (nonatomic, weak) NSString *stringProperty;
First our property has a locking term (nonatomic) and a
storage mechanism (weak) specified.
The nonatomic flag prevents the property from being
locked which means that multiple threads can access it
at the same time. By default, properties are atomic (so
they are locked).
Weak means that the property is not tied to the owner
(i.e. one can be released without affecting the other).
The basic collection classes of
the Foundation Framework
The basic collection classes of
the Foundation Framework
• NSSet, NSArray is immutable, so you
cannot dynamically add or remove items.
• Immutable arrays can be defined as
literals using the @[] syntax
• you’re likely to encounter the more
verbose arrayWithObjects: factory
method a class method
Creating Arrays
NSArray *germanMakes = @[@"Mercedes-Benz", @"BMW",
@"Porsche",@"Opel", @"Volkswagen", @“Audi"];
NSArray *ukMakes = [NSArray arrayWithObjects:@"Aston
Martin",@"Lotus", @"Jaguar", @"Bentley", nil];
NSLog(@"First german make: %@", germanMakes[0]);
NSLog(@"First U.K. make: %@", [ukMakes objectAtIndex:0]);
As you can see, individual items can be accessed through the
square-bracket subscripting syntax (germanMakes[0]) or the
objectAtIndex: method, is the standard way to access array
elements.
Creating Arrays
NSArray *germanMakes = @[@"Mercedes-Benz", @"BMW",
@"Porsche",@"Opel", @"Volkswagen", @“Audi"];
NSArray *ukMakes = [NSArray arrayWithObjects:@"Aston
Martin",@"Lotus", @"Jaguar", @"Bentley", nil];
NSLog(@"First german make: %@", germanMakes[0]);
NSLog(@"First U.K. make: %@", [ukMakes objectAtIndex:0]);
As you can see, individual items can be accessed through the
square-bracket subscripting syntax (germanMakes[0]) or the
objectAtIndex: method, is the standard way to access array
elements.
loops and conditions
Loops and Conditionals
Objective-C supports common looping and
conditionals. Here are examples of the
for(each), for(count), and while loops
loops and conditions
for (NSString *string in array) {
//Do Something
}
for (int i = 0; i < number; i++) {
//Do something
}
while (boolean == true) {
//Do something
}
loops and conditions
NSArray *germanMakes = @[@"Mercedes-Benz", @"BMW",
@"Porsche",@"Opel", @"Volkswagen", @"Audi"];
// With fast-enumeration
for (NSString *item in germanMakes) {
NSLog(@"%@", item);
}
// With a traditional for loop
for (int i=0; i<[germanMakes count]; i++) {
NSLog(@"%d: %@", i, germanMakes[i]);}
}
Main.m
open up Supporting Files/main.m.
we see the entry point to our application.
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
The UIApplicationMain method is called to start our application and basically says to
run the AppDelegate.
AppDelegate.h
AppDelegate extends
UIResponder and
implements the
UIApplicationDelegate
protocol.
AppDelegate.m
Application methods
(didFinishLaunchingWithOptions, applicationWillResignActive,
applicationWillEnterForeground, etc. )
These methods (part of the UIApplicationDelegate) are called when certain
events happen on the app object.
For example,
didFinishLaunchingWithOptions will be called when your app starts.
applicationWillResignActive is called when your app moves into the
background.
The majority of these (non-app starting) methods have to do with the app
going into the background when you should stop tasks from running, store
state, and more or when the application is coming back into an active state
UIViewController
Any ViewController you will create
will extends UIViewController.
Methods:
viewDidLoad,viewDidAppear,view
WillAppear,ViewWillDisappear/
DidDisappear
View
Lifecycle
UIViewController
• ViewDidLoad - Whenever I'm adding controls to a view that should
appear together with the view, right away, I put it in the ViewDidLoad
method. Basically this method is called whenever the view was loaded into
memory. So for example, if my view is a form with 3 labels, I would add the
labels here; the view will never exist without those forms.
• ViewWillAppear: I use ViewWillAppear usually just to update the data on
the form. So, for the example above, I would use this to actually load the
data from my domain into the form. Creation of UIViews is fairly
expensive, and you should avoid as much as possible doing that on the
ViewWillAppear method, becuase when this gets called, it means that the
iPhone is already ready to show the UIView to the user, and anything
heavy you do here will impact performance in a very visible manner (like
animations being delayed, etc).
•ViewDidAppear: Finally, I use the ViewDidAppear to start off new threads
to things that would take a long time to execute, like for example doing a
webservice call to get extra data for the form above.The good thing is that
because the view already exists and is being displayed to the user, you
can show a nice "Waiting" message to the user while you get the data.
View
Lifecycle
Lab
•Create
ViewController
Assignment
1- Searching for the following topics in Objective-C
1- NSARRAY - NSMutableArray
2- NSDictionary - NSMutableArray
3- Autolayout
4- How to make Button rounded border for add Button
2- Create an View Controller that can take the student name and save student object in data collection
like "NSMutableArray"
3- after press the save button a result label will display “Hello ” + name of the student
4- Create an method that can print tall the student names that have been entered before
5- Create a button in the screen that can preform the above action for print function loop for the enter
student name
6- Advanced task :
search for an UINavigation and how to use it to navigate form one screen to another
THANKS
▸ Skype : amr_elghadban
▸ Email : amr.elghadban@gmail.com
▸ Phone : (+20) 1098558500
▸ Fb/amr.elghadban
▸ Linkedin/amr_elghadban
▸ ios_course facebook group : https://www.facebook.com/groups/
1161387897317786/
WISH YOU WONDERFUL DAY

More Related Content

What's hot

Multithreading on iOS
Multithreading on iOSMultithreading on iOS
Multithreading on iOS
Make School
 
Ruby on Rails Developer - Allerin
Ruby on Rails Developer - AllerinRuby on Rails Developer - Allerin
Ruby on Rails Developer - Allerin
Lauree R
 
Introduction to Underscore.js
Introduction to Underscore.jsIntroduction to Underscore.js
Introduction to Underscore.jsDavid Jacobs
 
Performance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesPerformance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best Practices
Doris Chen
 
Distributing information on iOS
Distributing information on iOSDistributing information on iOS
Distributing information on iOS
Make School
 
Flex data binding pitfalls: 10 common misuses and mistakes
Flex data binding pitfalls: 10 common misuses and mistakesFlex data binding pitfalls: 10 common misuses and mistakes
Flex data binding pitfalls: 10 common misuses and mistakes
Elad Elrom
 
Wade Not in Unknown Waters. Part Four.
Wade Not in Unknown Waters. Part Four.Wade Not in Unknown Waters. Part Four.
Wade Not in Unknown Waters. Part Four.
PVS-Studio
 
Creating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSCreating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JS
Akshay Mathur
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core Data
Make School
 

What's hot (13)

Extjs
ExtjsExtjs
Extjs
 
Multithreading on iOS
Multithreading on iOSMultithreading on iOS
Multithreading on iOS
 
Ruby on Rails Developer - Allerin
Ruby on Rails Developer - AllerinRuby on Rails Developer - Allerin
Ruby on Rails Developer - Allerin
 
webworkers
webworkerswebworkers
webworkers
 
Introduction to Underscore.js
Introduction to Underscore.jsIntroduction to Underscore.js
Introduction to Underscore.js
 
Performance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesPerformance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best Practices
 
Distributing information on iOS
Distributing information on iOSDistributing information on iOS
Distributing information on iOS
 
Flex data binding pitfalls: 10 common misuses and mistakes
Flex data binding pitfalls: 10 common misuses and mistakesFlex data binding pitfalls: 10 common misuses and mistakes
Flex data binding pitfalls: 10 common misuses and mistakes
 
Wade Not in Unknown Waters. Part Four.
Wade Not in Unknown Waters. Part Four.Wade Not in Unknown Waters. Part Four.
Wade Not in Unknown Waters. Part Four.
 
Creating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSCreating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JS
 
Lecture 3-ARC
Lecture 3-ARCLecture 3-ARC
Lecture 3-ARC
 
Angularjs
AngularjsAngularjs
Angularjs
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core Data
 

Similar to 03 objective-c session 3

iOS Multithreading
iOS MultithreadingiOS Multithreading
iOS MultithreadingRicha Jain
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
Amr Elghadban (AmrAngry)
 
iOS Course day 2
iOS Course day 2iOS Course day 2
iOS Course day 2
Rich Allen
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsPetr Dvorak
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOS
Petr Dvorak
 
Backbonejs
BackbonejsBackbonejs
Backbonejs
Knoldus Inc.
 
The Future of the Web
The Future of the WebThe Future of the Web
The Future of the Web
Ray Nicholus
 
10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds
Stuart Lodge
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Andres Baravalle
 
Objective c
Objective cObjective c
Objective c
ricky_chatur2005
 
Java oop concepts
Java oop conceptsJava oop concepts
Java oop concepts
Syeful Islam
 
CSc investigatory project
CSc investigatory projectCSc investigatory project
CSc investigatory project
DIVYANSHU KUMAR
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)
Netcetera
 
iphone presentation
iphone presentationiphone presentation
iphone presentation
Dhananjay Fartyal
 
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
smn-automate
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to Distribution
Tunvir Rahman Tusher
 
The Pillars Of Concurrency
The Pillars Of ConcurrencyThe Pillars Of Concurrency
The Pillars Of Concurrencyaviade
 
Parsing in ios to create an app
Parsing in ios to create an appParsing in ios to create an app
Parsing in ios to create an appHeaderLabs .
 
Parse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & TricksParse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & Tricks
Hector Ramos
 
Data herding
Data herdingData herding
Data herding
unbracketed
 

Similar to 03 objective-c session 3 (20)

iOS Multithreading
iOS MultithreadingiOS Multithreading
iOS Multithreading
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
 
iOS Course day 2
iOS Course day 2iOS Course day 2
iOS Course day 2
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOS
 
Backbonejs
BackbonejsBackbonejs
Backbonejs
 
The Future of the Web
The Future of the WebThe Future of the Web
The Future of the Web
 
10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Objective c
Objective cObjective c
Objective c
 
Java oop concepts
Java oop conceptsJava oop concepts
Java oop concepts
 
CSc investigatory project
CSc investigatory projectCSc investigatory project
CSc investigatory project
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)
 
iphone presentation
iphone presentationiphone presentation
iphone presentation
 
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to Distribution
 
The Pillars Of Concurrency
The Pillars Of ConcurrencyThe Pillars Of Concurrency
The Pillars Of Concurrency
 
Parsing in ios to create an app
Parsing in ios to create an appParsing in ios to create an app
Parsing in ios to create an app
 
Parse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & TricksParse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & Tricks
 
Data herding
Data herdingData herding
Data herding
 

More from Amr Elghadban (AmrAngry)

Code detox
Code detoxCode detox
08 objective-c session 8
08  objective-c session 808  objective-c session 8
08 objective-c session 8
Amr Elghadban (AmrAngry)
 
07 objective-c session 7
07  objective-c session 707  objective-c session 7
07 objective-c session 7
Amr Elghadban (AmrAngry)
 
05 objective-c session 5
05  objective-c session 505  objective-c session 5
05 objective-c session 5
Amr Elghadban (AmrAngry)
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
Amr Elghadban (AmrAngry)
 
01 objective-c session 1
01  objective-c session 101  objective-c session 1
01 objective-c session 1
Amr Elghadban (AmrAngry)
 
00 intro ios
00 intro ios00 intro ios
10- java language basics part4
10- java language basics part410- java language basics part4
10- java language basics part4
Amr Elghadban (AmrAngry)
 
9-java language basics part3
9-java language basics part39-java language basics part3
9-java language basics part3
Amr Elghadban (AmrAngry)
 
8- java language basics part2
8- java language basics part28- java language basics part2
8- java language basics part2
Amr Elghadban (AmrAngry)
 
7-Java Language Basics Part1
7-Java Language Basics Part17-Java Language Basics Part1
7-Java Language Basics Part1
Amr Elghadban (AmrAngry)
 
3-oop java-inheritance
3-oop java-inheritance3-oop java-inheritance
3-oop java-inheritance
Amr Elghadban (AmrAngry)
 
1-oop java-object
1-oop java-object1-oop java-object
1-oop java-object
Amr Elghadban (AmrAngry)
 
0-oop java-intro
0-oop java-intro0-oop java-intro
0-oop java-intro
Amr Elghadban (AmrAngry)
 

More from Amr Elghadban (AmrAngry) (14)

Code detox
Code detoxCode detox
Code detox
 
08 objective-c session 8
08  objective-c session 808  objective-c session 8
08 objective-c session 8
 
07 objective-c session 7
07  objective-c session 707  objective-c session 7
07 objective-c session 7
 
05 objective-c session 5
05  objective-c session 505  objective-c session 5
05 objective-c session 5
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
 
01 objective-c session 1
01  objective-c session 101  objective-c session 1
01 objective-c session 1
 
00 intro ios
00 intro ios00 intro ios
00 intro ios
 
10- java language basics part4
10- java language basics part410- java language basics part4
10- java language basics part4
 
9-java language basics part3
9-java language basics part39-java language basics part3
9-java language basics part3
 
8- java language basics part2
8- java language basics part28- java language basics part2
8- java language basics part2
 
7-Java Language Basics Part1
7-Java Language Basics Part17-Java Language Basics Part1
7-Java Language Basics Part1
 
3-oop java-inheritance
3-oop java-inheritance3-oop java-inheritance
3-oop java-inheritance
 
1-oop java-object
1-oop java-object1-oop java-object
1-oop java-object
 
0-oop java-intro
0-oop java-intro0-oop java-intro
0-oop java-intro
 

03 objective-c session 3

  • 1. Developing Mobile Application Ios : session # 3 By : Amr Elghadban
  • 2. AMR ELGHADBAN ABOUT ME ——————————— SOFTWARE ENGINEER FCI - HELWAN 2010 ITI INTAKE 32 WORKED BEFORE IN - Tawasol IT - Etisalat Masr - NTG Clarity
  • 3. property @property (nonatomic, weak) NSString *stringProperty; First our property has a locking term (nonatomic) and a storage mechanism (weak) specified. The nonatomic flag prevents the property from being locked which means that multiple threads can access it at the same time. By default, properties are atomic (so they are locked). Weak means that the property is not tied to the owner (i.e. one can be released without affecting the other).
  • 4. The basic collection classes of the Foundation Framework
  • 5. The basic collection classes of the Foundation Framework • NSSet, NSArray is immutable, so you cannot dynamically add or remove items. • Immutable arrays can be defined as literals using the @[] syntax • you’re likely to encounter the more verbose arrayWithObjects: factory method a class method
  • 6. Creating Arrays NSArray *germanMakes = @[@"Mercedes-Benz", @"BMW", @"Porsche",@"Opel", @"Volkswagen", @“Audi"]; NSArray *ukMakes = [NSArray arrayWithObjects:@"Aston Martin",@"Lotus", @"Jaguar", @"Bentley", nil]; NSLog(@"First german make: %@", germanMakes[0]); NSLog(@"First U.K. make: %@", [ukMakes objectAtIndex:0]); As you can see, individual items can be accessed through the square-bracket subscripting syntax (germanMakes[0]) or the objectAtIndex: method, is the standard way to access array elements.
  • 7. Creating Arrays NSArray *germanMakes = @[@"Mercedes-Benz", @"BMW", @"Porsche",@"Opel", @"Volkswagen", @“Audi"]; NSArray *ukMakes = [NSArray arrayWithObjects:@"Aston Martin",@"Lotus", @"Jaguar", @"Bentley", nil]; NSLog(@"First german make: %@", germanMakes[0]); NSLog(@"First U.K. make: %@", [ukMakes objectAtIndex:0]); As you can see, individual items can be accessed through the square-bracket subscripting syntax (germanMakes[0]) or the objectAtIndex: method, is the standard way to access array elements.
  • 8. loops and conditions Loops and Conditionals Objective-C supports common looping and conditionals. Here are examples of the for(each), for(count), and while loops
  • 9. loops and conditions for (NSString *string in array) { //Do Something } for (int i = 0; i < number; i++) { //Do something } while (boolean == true) { //Do something }
  • 10. loops and conditions NSArray *germanMakes = @[@"Mercedes-Benz", @"BMW", @"Porsche",@"Opel", @"Volkswagen", @"Audi"]; // With fast-enumeration for (NSString *item in germanMakes) { NSLog(@"%@", item); } // With a traditional for loop for (int i=0; i<[germanMakes count]; i++) { NSLog(@"%d: %@", i, germanMakes[i]);} }
  • 11. Main.m open up Supporting Files/main.m. we see the entry point to our application. #import "AppDelegate.h" int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } The UIApplicationMain method is called to start our application and basically says to run the AppDelegate.
  • 13. AppDelegate.m Application methods (didFinishLaunchingWithOptions, applicationWillResignActive, applicationWillEnterForeground, etc. ) These methods (part of the UIApplicationDelegate) are called when certain events happen on the app object. For example, didFinishLaunchingWithOptions will be called when your app starts. applicationWillResignActive is called when your app moves into the background. The majority of these (non-app starting) methods have to do with the app going into the background when you should stop tasks from running, store state, and more or when the application is coming back into an active state
  • 14. UIViewController Any ViewController you will create will extends UIViewController. Methods: viewDidLoad,viewDidAppear,view WillAppear,ViewWillDisappear/ DidDisappear
  • 16. UIViewController • ViewDidLoad - Whenever I'm adding controls to a view that should appear together with the view, right away, I put it in the ViewDidLoad method. Basically this method is called whenever the view was loaded into memory. So for example, if my view is a form with 3 labels, I would add the labels here; the view will never exist without those forms. • ViewWillAppear: I use ViewWillAppear usually just to update the data on the form. So, for the example above, I would use this to actually load the data from my domain into the form. Creation of UIViews is fairly expensive, and you should avoid as much as possible doing that on the ViewWillAppear method, becuase when this gets called, it means that the iPhone is already ready to show the UIView to the user, and anything heavy you do here will impact performance in a very visible manner (like animations being delayed, etc). •ViewDidAppear: Finally, I use the ViewDidAppear to start off new threads to things that would take a long time to execute, like for example doing a webservice call to get extra data for the form above.The good thing is that because the view already exists and is being displayed to the user, you can show a nice "Waiting" message to the user while you get the data.
  • 18.
  • 19.
  • 21. Assignment 1- Searching for the following topics in Objective-C 1- NSARRAY - NSMutableArray 2- NSDictionary - NSMutableArray 3- Autolayout 4- How to make Button rounded border for add Button 2- Create an View Controller that can take the student name and save student object in data collection like "NSMutableArray" 3- after press the save button a result label will display “Hello ” + name of the student 4- Create an method that can print tall the student names that have been entered before 5- Create a button in the screen that can preform the above action for print function loop for the enter student name 6- Advanced task : search for an UINavigation and how to use it to navigate form one screen to another
  • 22. THANKS ▸ Skype : amr_elghadban ▸ Email : amr.elghadban@gmail.com ▸ Phone : (+20) 1098558500 ▸ Fb/amr.elghadban ▸ Linkedin/amr_elghadban ▸ ios_course facebook group : https://www.facebook.com/groups/ 1161387897317786/ WISH YOU WONDERFUL DAY