Upload
strikerjax
View
213
Download
0
Embed Size (px)
Citation preview
7/24/2019 IOS Essential Notes
1/4
IOS Essential Notes - Lydia.com IOS Course
-------------- @Property@interface Myclass: NSObject {}
@property (nonatomic) int score;------------------------------------------------------------------------------------atomic - thread safe : Its the defaultnonatomic - fast but not thread safe------------------------------------------------------------------------------------Strong (we own it, strong reference) and weak (weak reference)------------------------------------------------------------------------------------
@Synthesize (older code use this to generate getter and setters but not requirednow)------------------------------------------------------------------------------------
bob.score = 100; [dot syntax works only for getter and setter methods]
------------------------------------------------------------------------------------MVC:====Model : text files, DB, Image files etcController : Objective C [ .m & .h Xcode files]View : storyboard and .xib files
Action : Flows from View to Controller (method) ex: button click calls a method.This methos is the actionOutlet : From Controller(IBOutlet* deiniftion) to ViewA single UI element (Text field etc) can be both Outlet and Action
------------------------------------------------------------------------------------------UI elementsView --> Utilities --> Show object lib------------------------------------------------------------------------------------------IBAction - When the view element is dropped into the view Controller.m1. Drag a button in the implementation - IBAction2. Drag a text into the @interface - IBOutlet
pointing to the margin next to the Outlet Code in the View Controller shows thelink on the Storyboard
------------------------------------------------------------------------------------Dismissing Delegation:------------------------------------------------------------------------------------First Responder : [textfield resignFirstResponder]----------------
touchesBegan: (NSet*)touches withEvent (UIEvent *) event{
7/24/2019 IOS Essential Notes
2/4
[self view endEditing:YES]}------------------------------------------------------------------------------------Video 4_4_DismissDelegation:Make the ViewController the 'delegate' for the text field.Events from Text field which the delegate handles: When the text field is beginning editing, Clear field
------------------------------------------------------------------------------------Delegate Protocol : Delegate class adheres to this.Use brackets to implement
1. Read the Delegate Protocol2. Delegate class defined.3. Implement the required methods4. Connect the delegate class to the delegated object.
------------------------------------------------------------------------------------Video 04_06:Show Message Window:UIALertView : initWithTitle
[myAlert show]
Hit Home Button : then app is not killed, but paused?------------------------------------------------------------------------------------main.m
UIApplicationMain(argc, argv, nil, delegate); //delegate is AppDelegate.mUIApplicationMain() : Pass Delegate
----> UIApplication----> Calls Primary UI file (Storyboard/xib) : n
othing is visible yet
----> Calls your app delegate----> UIWindow : transparent, exists for the lifespan of the app
----> Loads View Controller into the UIWindow---->
While app is loading:# applicationDidFinishLoadingWithOptions() (LifeCycle methods in AppDelegate)# viewDidLoad & viewWillAppear (LifeCycle methods in viewController)
After App loads# applicationDidBecomeActive()# viewDidAppear() (viewController)
# Go through AppDelegate.
--------------------------------------------------------------------------------------------------------------------------------IOS Project Templates:Single ViewMultiple ViewPage ViewTabbed Application : Clock App
7/24/2019 IOS Essential Notes
3/4
Utility App : With a flip view : IOS 7 moved away from this styleEmpty Appl.OpenGL & SpriteKit--------------------------------------------------------------------------------------------------------------------------------Do a SingleViewApplication first. Check out the Exercise files--------------------------------------------------------------------------------------------------------------------------------DatePicker or Picket : Connect a DataSource and Delegate for handling the selectRow etcUse UIDatePicker Protocols for defining these.- Connect--------------------------------------------------------------------------------------------------------------------------------DatePicker example :Connect DatePicker as Outlet and Button as ActionAn Outlet also lets you access to a control(read, write)NSDate *Chosen = [self.datePicker date];// EEEE represents date of the week in full ie., Monday etcNSDateFormatter has setDateFormatter:@"EEEE" //100s of different formats--------------------------------------------------------------------------------------------------------------------------------- define a property in .h and it becomes a public variable- define a property in .m and it becomes a private variable
--------------------------------------------------------------------------------------------------------------------------------- Practice arrays and different ways to use them--------------------------------------------------------------------------------------------------------------------------------TableView Notes:Using Plist file and load the values into the table view.Copy the plist from mac dir to the Xcode Project Supporting files.Loading the Plist into runtime use:
In viewDidLoad:NSDictionary* : It is not a 0 based data structure.NSURL and NSBundle
- urlForResource- Use the URL to make the NSDictionary??
NSDictionary dictionaryWithContentsOfURLNSDictionary allKeys
Protocoal Methods to Implement :- numberOfRowsInSection()- cellForRowAtIndexPath()
declare variable of type UITAbleViewCellCall dequeueCellForReuseCellWithIdentifier
- Efficient way to dequeue any cell- Provide one cell to implement scrolling and resuing cells. Utilities Panel. Attribute details inspector on RHS. In 'Prototype Cell' usevalue 1
Identifier : 'cell' (same as in code)--------------------------------------------------------------------------------------------------------------------------------- Default Multi View template app has both Nav. Controller and- Every method has a description method.
7/24/2019 IOS Essential Notes
4/4