You are on page 1of 322
| PHONE Class notes By Mr. Balu sir tus NARESH @ N ( technologies SOFTWARE TRAINING & DEVELOPMENT SRI RAGHAVENDRA XEROX Software languages Material Available Boside Bangalore iyyager Bakery .Opp. COAC, Balkampat Road, Ameerpel.Hy €§ 9951596199 26/09 [2013 iPhone BIOL Rg = 150 Smartphones & fablets are became mact popular in the masket became those all are ain) Operating System, which OS coe are using in mobiles & fablel. those. are catlect mobile operat "9 Sysiem Wistoay of mobile OS i- IS eS > faom 1979-1999 All mobiles are woalei ng with the help OF embeded system only > Jn the year cf 1993 fart Smarrphone es is actecued wrth the name called IGM Semen > In the year of 1996, Palm os intseduced 19 the mark ef > To the year of 1996, Mictosoft aeleagect Windows CE OS for mobiles. => Tn the year of 1999, Nokia introduced S4o Of Fos ther own products 7 Tn the yeu of 2000, Symbian os is introduced in the Manet with 94 technology > In the year of good enhancement of Polm of is IN sou cect > In the year of 2007, Nicrosoft jntaoduced enhancement of Windows CE Os 7 Tn the yeat of 9002, BlackBerry inksocluceal theis ows OS > Em the Year of 9005, NoKia seleayed Maemo os ” > In the year of Poot , Apple coapogation Leleaie ther Own OS called ios , with Ba Feakues 7 In the year Qook, goagle \ntsoduced Ancioid os 7 Eo the year of 2009, Samsung iMtroduced BAA OS. > Fo the year of 910, Micdocoft introdtecedl Wind oes OS fa Windows mobile >In the year of 2019. Mozilla Coaposalion , wlsoctu ced Fiaefox Of fox mobiles ? In the year of 2013, BlockBery seleared RIM CRerearch In Motion) os ¥ Commen Opercting System fox Mobiles t- ') Android Faom Google. Tt is a faee and an open Source 2) BADA faom Samsung etectaonies , it is a closect Socace 3) Symbian Prom Nekia, if ig an open ficensed sowes- 4) Windows Phone from MicroSoft, it ig a Closed source 5) BlackBesny Prom QNX software , TH is a Closed source. 6) Bawo From Qualcomm, if is a closed source 64) Windows § Faom Micsosoft, Closed Somee 10S CiPhopne Operakng System) :- ) Th ts a own os of Apple Composation. 8 2) By using this oS only, Apple devices are toosks like iPhone , iPad , iPod , Apple Tv 3) “The osiginal name of iS is “OSX” & it way aenamed as i@F on june'T' Lolo &) The Fair vettion oF iOS is seleased on June 2g% Soot Cvenion £0) 5) On Taly 1 gooR [0S . 2nd vettion ig seleased he FO. 6) On June ti dog 10s Sad version is aateay ed ie 30 4) On Feb 274 gee Bolo {sh generation of iPod seleoue 19 the maakeb te 31 8) Ash grneahon iPad is seleaued with 3.2 version 4) On June 28+ Gola, 10S 4-0 is seleated with mui task Features (0) The iPod and genwation & iPhone 34 implemented based oa 4:0 only 11) On June 6 gott , IOS A@ecsed 5-0 with Apple TV and many mose Features ke imenege chat, (Cloud, Awter integerah en ) US 60 can support atl iPad version. iPhone 34,365. 4, hS modelt alto atong with iPad 33d & 4th geneakon. 1By On Sept 19 Yo12, iOS FO ig intsoduced with Siai, facebook integration, mops & lol Of new foakstes CSivi foa bland people) 1a) On Sept. 872013, 10S FO jntacctuced In Market with 1 ent ef jl Sas my enhance me of upcoming vetions 15} To devetope any kind of iOS appl” coe need MAC OS with Io ox higher Configurations is) fos jos Jeloded appl”, we uequise fo we IDE Ve Xcode Clatet vewtion § sapposking fox iOS +0), "Objective C Objective C is a genre purpose high level onyect Osierbed Programing languoge. Owjechve C paogsaming language derigned by Wing © and Smathtatk-to Paogsaming languages Smatitallet ig a second genealed Object aniented pacgr- Orning language Objective Cc prog saming language follows Smaritakk messege Paring Style ( syatax ) cong with “C’ puogsam - ing language concept Obyeclive C ig @ main programing language used by Apple for the OS x & ios Operating SyStem, In \dtos Dennis Ritchie wag developed C progr aming languoge but , His language is not | popular UNHL unix og ig not Adeared. In \9RO'S Baad J. Cox Aeignect ObjecHve C tonguage based on Smatttalk-go 2 C language To the year of 198%, objective C language developed its Nbesary & deveXopment envisonment called NEXTSTEP by NexT sSofkoare Jn 1992, Objective C languoge became Open Soutce: Tn 1994, Next computer & Sun Miesocystem aeleas ed A Standerdired specification of the NextStep system Coued OPENSTEP Face Software foundation implementian at OPENSTEP ig called GNUSteP A Linux based GNOStep devetopment envisonment fs Catted Linuxstep: On Oecomber 90,1996, Apple Computer hand over NexT SOFAS, NexTSTEP , OPENSTEP envisenmens to release Apple's OS coued OS K In oot, Apple Release an updated te object ve Cc Vong uage ig called GbelecHve-C 20 Apple Version of developemens envidonment ‘sg caLled Cocoa : 2t/09 } 2013 axe imp lem enking any program by ust Objective © then, extention of the file is ‘#m! When we Objective C sgteated appl” can be detigned , compiled & aun by using feaminal & LOE alo. TF we sequise fo we He ZOE, then mut be sequined fo go for" Xcode’ only Xeode IOE can be find fiom the system with the help oF “finder” When we open xeode TOE then, In left side panet we having a open called “ Cacake new projeck” oL ae to ‘file’ > New ~» pao’ ect Alter choosing NeD~ Paoject coe having © option caltect “choose a template fox your nem project” Select “OS X' OpHon fuom left side panel & select we type ab “command line tool” After Selecting Next” button we need to provide product name he app\” name, company name k sect ype aa” foundation” ¥ Objective ‘C progaaming basic stand a) 4 impost < foundation ( Foundation-h > ink main Cint aage , conat chax % axgv £)) NSAutoacleate fool * pool =[[ NSAutoselease Poo! alloc] init]: NSLog (@"WUcome iPhone”); {cod daain]; AULD 07 1) Foundation is a framework which paoviclel standard Ue Dtlated oll paadefined clames of Framecwoaks or interface infoamosion ~ 2) age is o vatioble of type Tateger which holds total no. of asjuments values which is panedt fo mein fur 3) GagV is B voriable of type chor # which holds actual aagument vatue whieh is paued to main function H% NS AutorelearePool :- Ti ig a paedefined interface oa cla which Is ayrailable to foundation Frameooak pool is o object of type Ns Autoael eare Poo) which holds aeferece oF fool memosy o e eahn ool of By using alloc method we are cueakes P memoay for Curent appl”. Oy using ‘init’ method, dynamicatly created memory will inifialize- “dsain’ ig a predefined method ay wing this memod we are deatocading dynamically cyeatedt pool memody._ Cxample 2% # impost < Foundation / Foundation:h > ink mala Cink asge , const chor # orgy £J) @ antoseieare pool { iat ab; NS Log (@” Enter 2 values”); Hf paint C™ Enter 2 values) Scant (*¥d rd", &0,&b); NSLog (@ Sumo} yd+%d= ¥h"0,b Arb): MPU C™\nsum of Yd 4 Yd =7.dA,b,Atb); $ To compile the Pprogaam we sequize to Cue “Build” option. Mac Book —-> command +Q Windows —> window +B Pacduct —s Guild To wn of execule the Ploguam we sequlse “Run” orton Mac Book —4 command + & Windows —3 Window +R Product —s Run while program is SuNnieg if we sequise fo ctop then go fox “stop” oplon Mat Book —> Command + * Windows —> Window ++ product —» Shop Genera Xeede contaiing Hace layouk views i€ Navigahes. view , debug asea , uhli Hes Noavig atoa View is lett side panel, Ae bug area ig bottor ¢ ; , panel, Utility is Right side panel te Cocoa Ioexagies * NgLog Zt is a predefined method Which Is available in foundation Frameooate by waing this pagdefined method we cas Psint the dota on console ie debug window When we are coosking eoith NsLog method, it can take Any Mo of argument. bur Piast argument mut NSS bins type. Thakk Why we aequise te incticate "@" symbol: Geneatly in C paograming language when we are wing pasotf if tales chor * , thats why “@ gpecifreat doen't sequisedl User] home] liberory /eveld per] Xcode /Deriveddala /Paogs 30/09 2013 (a) Ls guitd c u Procduets a v Deloug Shell v t ~ frog Affe Conatastcting any applicalion in jOS executoble file or Shell file can be locate in user{homef liberaty [developer/ xcode/ derived data. x Dalotypes $- : ') In Objectve C we havin Asis ¢ 2elated datatypes and NextStep seated datatype also . 2) In Objective C Anste seloted dalotyper ore ( chop — 7.0 shoak int — 7 “hx, 7 ho Unsigned shoad ink — FRU “hx, %ho ik long int — “dt, /dx, / So. Float “1, LR, LO unsigned iW — YU LK LO w= long long labo te Ui y Merle us Re 1g, La. 9 : double = — YER, 1g ha \ - % ; i o ong double, PLP, Phle, Aly Bool : id ee 3) By using Bool datatype we Aenuiited fo store boolean Volues 1@ TRUE ox PALSE, ox YES o4 NO a) id is a genie datatype in ObjecHve © which can hola any Kind of data values 6) By usieg id databype it is possible to implement dynamic casting Ve ot auokme it can hold any type of date \) Open Xtode TOE by using finder 2) Carato a New Xcode paoject 3) from “choose template’ option select “application” undes 0S x 4) Select the appl? tye 3 ‘Command Line tool’ 5) Give the product name as “Prog 2” Select the type as ~ Foundghon" 6) Then save the PSojeck femplake in any selected disectosy Code in “Main-m” H impoar ¢ foundation | Foundation-h> ink mas Cint aage , conat chor angy CJ) NisAuboaseasePool ¥ pool = [LNSAWoreeatePool able} init]? QOolL isGool = VES; NStog (@"7d" , 1g B00! 3: Nslog (@°y.@" loot) @rYes" s @* wo"); MW Painte C%S* IsBool 2 “ YES": No"); Char achay ='a' unsigned cha AnVnsignedchas 2d, NSleg (@ ~The WH C1 ASCET Mumber Zand" f. , achar achare Nslg C@™7C" AnUagignedchat.) ; Shoat ashoat = - 32763 Unsigned chogr anUnsgnedShod = 66635; NSLog (@®*Y hd ashosy ); NSLog C@"7- hv", An Unsigndgnogy ) ; Jat ANT = ~V1UF4 836u8 ; unsigned int an Unsigned zd: 42944967095; Nslg (@*%.d" Gatos); Nstog (@°%A", aavasigned Int) Long along = 99233 720363 G4 498K 0} ursigned long anthsigned long = {Rugs 67 OST23 EBESE F NSlog (@* 41d", along) ; NSlog (@*7.1U" an Unsigned Long ); long ong along long = 992 346FG922 1012893 ; unsigned long long GaOngigned long long = (LU G3q-22 00109843 F ; Nslag C@*7 Ils", along tong )i Nstog C@*Y Wes anongeg ned Long Long ); CPoo\ drain]; dehurn 0; Ex i Psog3 > for Finching Size of the dalatype tt impoat © foundation / foundation-h > int mason Cint aage, comb chat Rasy Cc) ee & pools CLNsAukoseleare Pool aulocj init] i NSlog (@*sireot chars VII" sireof Cchar) 7 mL NSlog (@ ~ sire of unsigned chay : ¥.to", size of Cunsigned cher))? NSlog (@™ size of shoots 71d", sizeof ( Shost) i 32 “size ot v.ghoat : %Jd", streof CU-shait)) “2 NSLog Cc@ ——_—__ ——- int —— Cint) jeg ving ee CI) ad long, Chong 78 Oleg = ———» —— (eng); 78 long long —"-—— Clery long) 8 _ — ulong tong ——» ——— (Unley long ) 8 ee, Flo — (Heat); 7 4 — double §=—— *—————_ (double) i 7? long, double ~~ Clong double); 16 : ~ 00) ———. —— choot); —>\ eh ——"—— Cid Coot daain ; CA), 98 ARUN 0; 5 % Dakatyre Ronge seleate frtdetined Mesres + Signed chas mia: SCHAR_MIN max + SCHAR—~MAX UcH ARMIN Unsigned chor min + max: UCHAR MAX Shoat int min > SHRT_ MEN Max . SH RT_ MAX umigned shod int min: USART_MIN mox.: USHRT_ MAX signed int min : INT MIN max: TAT. MAK Vaxigned int min + QUINT MIN max: YINT_MAX long lat min 2 Lona Nin max: LONG-MAX Unsigned Vong ‘ink min : ULONG MZN Mon; ULONG MAX. long ‘ong int min: LLONG_-MIN mor LLONG MAK Unsigned long long inf min: GtBN ULLONG MTN Man: OLAONG_ MAX Floak min + FLT MIN & max: FLT-MAY Double min : DHSL-MEN max OBL_MAY MAX Array Encler : Size_ MAX ~ & Contso\ Plow Statements % aoe Objective C will suppoak three: ty pet OF consol Flea statement ie. Selection gtatement. — if elte , elie-if , switch. iteration statement —> while, fos, do. - while Jumping Statemenk -> baeak, continue, goto Carate command line too! appl” with the name paogh. impos < Foundation / Foundation hy Int main Caige int oage , contt chor & gv) NS Autosconse Pool %* Pool = [[NSAUuto selease Pool aloe] init i Shoat int A. bic.d 5 NS Log (@* Enter Value of 0"); Seanf (°Z hi", a); Nslog (@* Enter vatue of b")! SCONE” Zhi", @ bd; NS log C@™ Enter vole of care Seanf (SZ hi", & ¢); NSlog C@™ Enter valve of A"); Scant C*% Hi", BAD; if (assbWaz=c\las=d) 7 (@"¥.d is duplicate value”); 5 eueif (b= =cll bed) { NS log (@° 7d is duplicate Value"); 5 aeif (c= =A) ¥ asteg C@* LA ag duplicate Value”); we “NSLDg (@” There is no duplicate -vatue ") ; J (post duain] : aetuin © 7 5 Fromples’ Pag S Sum of 4+ & lost agit # Impoat < foundation / foundaHon- hy int main Cink age, eorat chas ougv) 1 @ awtseleate pool t in} vole ; shoat int sumed, temp i Nstog (@° Enter the value"); Scant ("y.d", & Vatue) s SUM = Nolue 7.10 ; Value = youe/ 10 ; tohile (vote 1-0) femp= value 7. 10; Value: Vatue /10; Nslog C@” sum of AHA DHE s AT" femp, sum, temp seum)/ 3 AMANO; j G6: Pug Changing He caye OF leew &. st impost < Foundation / foundation-h> \Ok mada Cink ange, cont char x % oagv LI) i @ autoclecse pool chad sty ClooJ ; Shost iat Cindex}; paint C° Enket a staing"); get Cts); U geanf (™%S", st); fox Cinder =0 j strCindex] 1=*\o' ; index ++) iF CstaCindexd >="A' RG staCinder] ¢='Z') Sra Cinder} = Sta Cindex} $32.5 eke Hf Cctafinder]>='a' gg sta Cinder} <= 2") Sta Cindex]- sha LindexJ- 32; 4 I NS tog (@" Staing dota: %5"\ sta) i esintt C*starng dota: %g", sta); f aetun 0; t [P° Weleome fo Naresh ZT > WELCONE TO PARESH it Gxo Prag. FaneHon # Functions pecocho my To C programing language we having four types of od defined fun? & those a funchons axe suppoated-in objecHve Cc abo. he ‘) No aekuan type with Mo parameter D) Retuin type withour poramerer 3) Rekun type with Parameter. 4) No athun type ewith parameter 4 Impast ¢ foundakion / foundation h > Noid abc c) NS Log C@" Helow "); fi Noid gum Cint x, inty) * stag C@sam of KtY rH) HYDE j nt sumVatue C) int r= lo, Yr2o; oetutn x+y D3 int addnum Cint x, ity) t bat aeturny Ct 4); Aa} maid Cage int cag c, comt char * aug VC) NsAutosel ease Poolx Poo! =L ENS Autosei ease Poel atloe init] s abc c); int ab ; NS Log C@” Enter 2 Volue :")- Scant (*¥d7d", 2Q,Rb); Sum (1b); inks; S = SumvValue C), Ns log CB" Sumvotue! igs ya" a § = addnuum C 190,200 ; NSlo9C@" gum Votued igi%d, 9); C Pool chainy ; Det 0; j * Object Osiented Concept in Objective ¢ a Lf 2b ‘) Whenever a programing language supposts oops concept then iy is cabled Object owented Progecning lang uage- 2) Tn any Oop language we Having four Oops concepkt Ma) Abstraction b) Enapswolion 8) Poly moxphison AD Inheritance 0) Abstrackion;- Lis a concept of providing the infoumaton abou and entity solthout Any implementation Erexp' ©) Encapsulation : Tr is a concept of Providing the secutity for the data with the help of paivate od protected vostiabler, C) Polymoaphism * peso Tt is a concept of implementotion of method mutHple Hmy With game name A) Thhertance Deriving the properties of boue class to derived clo is called inheti tance. In objective @ we having Hoo types OF inheritance only Le. 1) Single inheitance 2) Mat level inhetitance \) When we aie devving a clay fuem single base clas (4 JS Catted Slagle inheritance. 2) Detiving a clas fom an enisting detived claus is Cottedt muttitevel inhesitance- Ghenever ave are WOAkKiNg ith COPS eoNceph we nest clames & objects ¥* Clous Tt is an wer defined datatype which is constaucted occoscling to sealHme anvisonment. Ve Seatlime object model infoarmaton. A class is an @entity of data membeu & member functions: Cvasiobler & methods) A clam ig ao bluepsint of an enthy. without any physical memoay Objects An object is a physical inutance of a class when we are Cae ating an object fos clay then only memosy will comtaucted Ray Kind of owecKVe C applicakon ¢ having Hues Podts 1) interface section ‘\) Emptementation section “) Program cechon, t/a] 2013 \) Interface Sections- This section contains clad declaraton & methed cleclaraHen only.) if doemst having any impiementation pork Objective ¢ aelated clauer contains koo types of membert & boo typed Of methods ie. non Static ot instance vasiables , SlaHc er variables Foa every object of the clay, if tHe physical memory \s constancred Coa o member. then it is catted non StaHe Or instance members fos Complete class Selated object only ones, memosy is cagated then it ig cabled Stabe membé? fox every object iF Coases ponding method is available Men ib is called Tnatanee method Fox compleke class xclated object ie only one. method \s awaslable then ik is called Static method. claus 3 . ae ol 7 x Syntoxe bo cacate a rom epesdexs @ interface clats_name :” Super clan c Data member ; § member Cunchons ; @ end ie % Syotax fo eteate iMlance Methed % — Caeturrty Pe) method name ; syntax fo caeate Static method 4 ‘ +Cacturnty pe) method name ; Notes + —' sign will indicates imptance methods , f “+ sign will indicates slakic methods. ( ex: ‘ . =< Ginterlace Empclau : NS Object vnatan® “ ink ids ——, name char aame [36]: /edodo 2 Sod int gal ; quseteeCon}t) Stoic Moat pf; _ «static fi (Sumse! member. —Cvoid )setempdata ; ~Cvoid) gebdata ; 5 / = d¢ a Spit Jt , : +Cint) Sumeat; see Obs 2} name} ‘ttonce cal yasioble. @ end. 2) Implementation Section ¢ This post contains implemerdation part of the clan. Method implementa” always sequised to compauct within Ye Implementad” gaat ¥ Syntax: @ implementation clau_name Meth oos @ enol Se: @ implementation EMpcLass ~ Wvoicl) set Emp Data I Code ~ Cvoid) getdota Y code + Clint) SumSol. N code AULA Chakemet ; 5 @ end. 3) Program SecHon 2 This section contain object cseaton & methocl caLling= Cae Example § *& Create a command line fool app coith the name catled clo Ext, ¥E impoat C foundation / foundationsh> @ interface Emectass ; NSObj ect int EMPiA; chor EmPrame 136); int Emp Sol ; - (Noid) Seber Bata ; ~Cvoid) Get Dato —Cint) SumSol + Cint) 2 ~ Cint) Ger Sotaay ; @ end @ Implementation EMPCLASS — (void) Set Emp Data Emp id =tot; Strcpy C EMPrame, Reyeth") EMPgal = \So00, ~(Noid ) Get Emp Data i IChos® Sts = Cohor®) cartoc(36, sizeot (cha); NStog @ “Enter Emp id, ") Scant C™ Zi", Empic) ; NSlog C@* Enter Emp name :") SE Felush Cétain); Sean FO"¥ 5", Emp Mame }; SUG CO” Eater EHP Satan) 5 Scant C“ v.d", EMP sat); 7 —Cint) SumSal: fink) Se ; Attuty (EMP) + 53); ( ~ Cins) Get Sotasy i arkuy EMPsah 5 i @ end tat main Ciat ayge , coms chan x ong vy a @ asutorereore pool stanemeet Inaba y EMPCLASS # obyt = CLENPCLASS altec init), Cobjiy Set Emp data]; EMPCLASS * Ob? = [[ENPCLASS auoe] init]; COby2 GekemPpatay ; int fojol Sol ; fotolsat= Cobjd Sumgal: Cobj9 GetSolary} 7; Nstog (®@* totet Salasy: 11", fotat sal); Coby atladny; Coby? setain | ; § aaa 0; J > : p> fidfrare [eal gop o[ NsObject_| P~? HHee obst hee init > Ser Emp Dada sean > Ger Ep Dabs be fol > Sum Sus, Qupelau _» | FMP CLASS > sebemp Dare INCRE SSS) I—> Gertempnara obja p> [ia]hane feel] > Emp 20 Ted Vithore [2600 EMP name 2 > Geb inp Doha J EMP Sod ao SerGep Dara 9 Suse Gebsar au Foetal: Copyi Sut > obd2 Gersaly L 2500 x Ronee sen XOK—— 03 / 10/2013 re 23 ee “when we are wosking class methed 91 stake metnod Yhen always it should be caued by using olay name ony - Clay methods can accey Slatic Variables of class. 1° Static members only we can accets. Fastance method sequired to Call with objeet name ony. Instance method can acceta instance vasiable of clan. Ns object ie a soot ax supercian of any i0s appl, which can provider foundakon Fromenmosk selated AU methods. when we are cucakng ony subclaus from NSObject clay then automatically Nsobject aetated methods cil included @eath *® @ autorselearepool 5 — This block will cacate NCAuloseleare Pool selated object awromaleally. & When contro! is Passing oukside of he block then tt coll ‘iain’ method. % Working with mulkiple Ale interface + Chen we Cre woaling with any (OS sedated appl”, then. Code will be implemented in multiple file Always interface gecHon should be sequised fo place in ‘sh’ Gile & implementation section: ment be sequtrecl fo place in ‘em’ fle examples Caeate an appl” of ype commandline tee with the name clam 6x 2. 3 Add o objective C file to the cured appl” File —> Bite New — file 0S X ——? ObjecHve-C clay * Code in FPsCla-h AF impoat < foundation / Foundation-h> @ intexface FpsClau : nisobject § Anh FES Floay ina; 5 ~(Woid) sek Et 2 Cink) i 95 ~ Cvoid’) Skins + Coot) Fj — Cink) Get EG ~ Cfloot’) Gebina — (Void) Ser eps Data : Cid ys withins(tload) f ; — (void) Get Fasdota ; ~ CFpsclang\ Add: (ppsclas Se )oby A WithODyect + (FPS Clan %® Joba; @ end. * Code in Fes Claas .m. # Impoat “FosClay.n” suser defined header fle @ implementation Fesclay —Cvoid) sek tt Cunt) i Fr =i; 5 ~Cvoid) Setins CHoat) & i img =F 5 HE Cing >= 19-09 nth += Cinbd ing Lint 4 She Fk + Cink) ins /i29 7 : : Ing sing & (RAE) ind [12% 125 1) Inga = Cinbiny [12a s a —Cint) Getfe Bekuan Eb > ~ Gloat) Getins a {etuin Ans f ~ (Vola) SetFpsDoba 1 LIMA) 1 withing: (Float) ¢ i fhe i; ings fj Tf Cim y= 12-0) FE t= Cit)iru/i2; = Wwe = = Cink) na [12 VG j ~(¥0id) Get Fps Date " nstogte “Ooj 2 Segulk: Va Z oF", EF, ins); = CFpsClous ) Bad : C PrsCloas* Joby A Withowyect + CFrsClauk) Ob) 6. ths Obj-A—aft + Obj85t Ins = ObyA Sl + OW GIN TE Cans d= 12-08) { fe += Citing / 197 Ins a— = Ciav) ins [19% 19 ; 5 SUN celh ; @end, * Code in main. m s- — + impost < Foundakion | Foundation -hy HE Imposd * Fes Clan h" int moin C4 int ange , Const chax * ogy) L @ aurtorete oye pool Fesclaus obji =CLFpsclar atloc] init); Conyd. ser Ph = 127 ; Cobjt Seti -38.60- NSLeg (@" Ov) # Serult « Ad" % OF" [objs GARE], Cob]d. Gets PesClaux obj? = CE FesClay atlocy init] Loby2 SetFps Data +18 -with ing 92.9) 5 LOb\2 Get Fps Dated : FesClors # 083 = CL Fpsclay atlecy init; Obj3=(0bj3 Add: bjt with obyect obj 2) - NStog (@"Obj3 desubls AO Loby 3 Geree) Loby3 Gebinal)i Coby 4 setaany ; Cow 2 setainy; Cob\3 avtainy; fh im fh oy Ae, hea lBe Wea | 3 ° i 1s 26 j_F ws Satlocle eae wit 5 Lopit Sethe: 125 Bop REY | aelain. -s Foxy 1 Sering 138-6] sebink X > ft }> [opjt Get PHT Ger ht X Fescion Co ia, >Cobjt Gating]; Get ian X Sere > Lob} 2 Settpsdala «ip > Get Ft within 92-9) > Serial Eh ins (obj 2 GetFrs Dade) ‘ | tet eels 35 > Setfps Data 2 > Get FpsDaka [obj 3 Add: obj 1 withobjecks 06) 2J. > Add > Cob) 3 Gerth; (ob) 3. SerFty; 04 / 10/2013 ty using Seer methods we sequised to autign instance vamable dota Ge wing Getler methods we can acced ingtance Vatlable data ‘Sep’ is a keyroord Which abloays ueferr current object “supes' is a Key wWosd a@bich always defers bare clan object. —Kox—-—— * Caeate a Commanel ine tool appl” ith the name ClauFx3- > Create a new clor With the name MathCclay,” * Code in MathClats-h # impost < Foundation -8/ Foundation: h> @ interface Mathclay : Nsobject f dowble sey uth; 5 (oid) Setaejult: (double) * —Cvert) Gebaes alte double: (void) Add # Clouble)v2 : (oid) Sub + Ccouble) Ve j “Cvoid) EMU: Cotowble) V2 5 “Wid) div: (double) V2; void) Hod : Clouble) Ve: @ end. * Code In MathClay mm : # Impoxt “math clos: h® © implementation MathCtay —Cvoid) Setserutt + Coub le) a AUuUu =A; : t ~Gouble) Getvegutl z f (void) Add : (double Ive seturn Aegublr | eee jp dsesuut = sesulh 4 V2 5 5 ' =CVoid) Sule Cdouble ) v2 . q aesult- = Vr ; : 5 4 ~CVoid) MUL: (double) V2 ; debull # =v2 > —(void) div : Cdoub\e) V2 aaa feta; -CVoid) Mod » Choultole) V2 = = fmod Caesuut, V2) 5 @ end. - Coo Code in main.m : # Impoat < foundation / Foundation-h > B impost “ MathClay-h” IDF masn Cink age , Comt Chas * aagveI) NS Autoreleaue Pools Pool = (ANSAutoseleare Bol atloe Jinit Ji double value! , Value? Chak operatos ; Bool operator IsValid = TRUE ; NSlogC@" Enter the valuer"); Scank (“ZI ZC %SE” Qvaluet, & operatas Ie Vall ,& Value?) : Moth Class ott -[[Mathélau atloc] init J; Cobyt Sebsesutt ; valued’ Suoitch Co peratos) ¥ ome}: Lovjt Add s value] ; beak ; Cores —': [Opjt Sub? Valued J; boneak j cose’: [obit Mu: Valued] ; baende + couety’ + Cobli div: vate tJ; brea; cases 7’, Cobjit mod: Value? J; baeale; afoul : Opesaton.S¢ Valid = FALSE ; baeale ; \F (Operatos Ts Valid = = TRVE) NS Log(@"7. IAF 7.C 7 .9IF,", valued , Oprrabs, Value?, Coy? Getrerur] ); 17 5 etic F NSLog C@ “Invalid input data" \; Cobjt setosoy ; Ceo arn); JUIN O ; j vgane) yo aw oo att oc 1 ae Supe _y WORE 10 +90! clo detain, aeautt 3:0 sub >| MathCla > serath tog eee clos — Add Cobyi Geld : Values Sub tebegult a [> Coit ads vslner7 : diy > Cobsd Gersoutt) ; GeneswU- Lace Getserulh * Hb impoat filename hy we AeqQuined fo vue when we We \oosti ng predefined Framemorks o3 heosler Piles *® te tmpoar © Filename-h’ vs aequised when we cue Imgosding- user defined header Filer fiom comment puvject diuectory ~ "@ properly disectosy ¢ og lioig013 8y waing this disectoay we can Provide acceuer method (setter ox Getter) for any class aelated members jo interface Section Generally Getier @ SeHet metro are catted ay alcenor method Which vequiued to make enable by wing “oe synincuize” Aisechive @ & property ditective woe require to place interface section, @ Synthasire diaective we sequise to place imelementanion sechon “@ properly’ disective having MmutH ple atisibukes Wee = © nenatomic :- => nonalomic’ meant muttple Heads can accent thad vasiable Non alomic’ is thdead uryate & fast in per farmance > non alomic’ ig not a defoutt atraibute so, we need to ure “non atooic’ keyword. > When we ase wosking with Non-olome membex then sesult Can be unexpected because muttiple trieac accel ing Same member fou. ex.- @ property Cnonatomic, sebain) NSShalng eName j @ cynthatize name ; ® atomics 7 alomic meant ony one thread can accey that member & unt) ament fuead Is not completed another Yaead cannot be accened. > By dePoutt Ony member's default atisibute ts * atomic! onuy - — atomic attaibute fs safe bat it is slow jn paoceu- eg: @ psoperty Csetoin) NSStaing R® Name ; Catomic is by dePoult ) @ syntharize nama ; @‘setain’ : —> when we ore ovelying “Setain' aHaibute then ald value will aetain & new Vatue will auign DP retain’ atisioute will gend the infoamaten that, old wolue seed fo be velecsed bemse oulgring new value. GB ead oaty : - This atlaibule ewe sequiue fo.ue when we need fo apply ‘sead onty’ property fo Q membag, —~ When we ae Opely ing \aead only * Paoperty theo Compiler doesnt generate getiet & geter method auto makicathy > If we ae Opply Stad ony -atisibue then, getter method only sequtied to Place in implementation section, > TP we ate making Synthasize fos. read only attaibute then it provides only getler method, if we are faging to acces the data te ong in by ing +" opertcatoa then it gives an eas. © sead wosite - THIS attSibuse will Jenerate set, & getter methods to modify the members of a day — > This attailoute ig a defo Pao pouky of a claw > When we are applying seadioaile atfaibubo then seller & geeles, both methods availoble in implementaton block ® strong Cis 4 = setain) t- > This atdibule will sous to the compiler that, holol the member in heap Grea unk! it ie not uelaln > By default al inutanee vasiables 2 local vatlabley axe ‘ Staong * only — Generatty, in cocoa Fuomeoak if 1g sequided to we “Stiong’ atl si bute. weak CiGS = UNsafe_unsctadned) 3- > Tt says fo the compiles , ceep this member at long i} is possible. > On weak members we Can} cath aetain os seleare obyect methods > When he weale memba ig deallocated then auso- matically pombes wil! get fo nil. ® afssign : > This akisibule will cooake like assignment operatos. = OUrign puoperty having Sete methods only ae) Gy uring this atailoute we can generate Cc paermiive type dabatypes - @® Coy: > Tis atidibule ig dequised for muutable Objects > Copy atldibute voll Speci ty thal old value wequised fo copy with new data * Cacate a commarctiine toot appl with name caue $4 > Caeate O new cla with thea name Emp Clary wCode in EmpClaw-hi- 4 imeoat ¢ Poundation | Foundalon.h) @ interface Empclau : Nsobyect int Empzd i NSStaing # name; Shoat int Age; unsigned int Solasy; © property Cnonatomic , seaduogite Jind Empid ; @ property Cnonadomic , xebadn) NSStsieg X name ; © property Cseoduosite) shast int ages ® property unrigned int Solaay ; — CIN) €SumSot : CEmpClay *) Ob) 8; @ ond * Code in EmpClas-m & impoas “ Emp +h" @. imple meokton Employ @ synthasize Empra, Ages @ syntharize name > @ synthasize ~Salosy ; —Unt) SamSoh + Cemp Clay) Obj B- 2 serann CsalOsy 4 of) B Salary); J 7 @ end. Co Code in mance te + impost < Foundation / Foundabion: h> # impost € “ Emp cla: h" lok “main Cint age , const char * ag vCJ) @ awoaclease pool § EmpCioaa x obj3 =[LEmpClay abloc]init] ; Covy4 Set Empid:}o2]: Cobji setName: @* Rajesh" J; Coys serAges 963; Cobj? serSolasy : 12300); NS Log (@ “Ene so: 7d" Covjt Empro) ); —" @" EmpName + ~@" Cobjt Gap Name J ): —™——(@* Emp Age + 4 hi", Cobjt Aged); "= C@ ~ Emp Solaray: U", Coby? Satosy)); int tsah, tsal = Lob) 4 SumSal sob j23; NStog (@ “ Total sol ory + %0h" been) Cok) @ ackease]; Coby d aeleared: AUUIN O; ag 5 Empl Peng am j qo, TERETIG Be age aoa] Eee Ncobjec! a 8 t EmpSelayy t Grand So pe eee eee k model C2 Soi Facey Class [eax > Fuel types ? Subject Colac 5 obj ~> frocip Quilreet® [> Cuore argaciy Foeulty depagrmeur seatirg copacitn cs ¢ a Moble as > Claw ty pe moaulectadi yon he 4 cibsxered 7 OF [lol 2013 % Create O command line te0l appl” with the name Clues 5 Carate Q nad clan with the name-called Cal Sub clas of P type nisorbject - & % Code in Carrh + impoat Cfoundakion | foundation hy @ interface Cor: NSovject t Nsstamy * brand ; —* —— mode ; —"— fue; —'— Color; Shoak int cubic ; Shoat ink scopasity + J + Cint) gexmyear j ~ Cioid) Ses Srand 5 CNSSising *)bname; ~ Cnssbring ®) Geb Grand 5 ~ (void) Seb Model - Cisstrirgmname; — CASS tring * ) GetModel ; ~ Cuvid) ce fact -CNSSHri0g) frames 7 Cxsstring *) GebFueb ; — C9018) Ser Colo » CNSSHTINg\ Cname.; = CNsString ) Geb Colox ; ~ (void) Setcubic : GMISC ; —Ciar) Getoubic ; —Cvoid) SetScapacity: Chale ; ~ Cink) Getscapacity; —Cnid) Aspley date; Bend. % Code in Coteme 8 \mpoat “Catch” @ ienprementation cox ; Stakic iar myeas ; +Cint) getmyeas ! myear= 2013 5 Aen myear > (void) Se Brand : (NSS tring &)bname i brand = bname: f CNiss tring &) GerBrond : Aeturn brood ; } — (void) Set Model : au] x) mname model < mname; ~ CNSsiring #) Gel Model i detain & mode; 4 ~ (Void) Set colod : CNSS4ring ) Sname { Color = Cname ; CNSsiringt) GebColos aww Cola; 5 ~C Void) M8 Setfual Crigstaing se) frame i fuel = frame ; —CNSStsi ng) Gerfuel deruin fuel; ~ (Void) SerEwdic 1 Cine : Cubic = C7 3 int) GekCubic Youn “cutbic 5 $ ~ (void) Seiscapa city! Cint)S t ane y= ~Cint) Gerseapacity L Beton Scapacity ; ~ void )atise laydata a NSLog (E"7B7@ 78 %@ fd vd" brand, model, fuel, cold, Cuble, Scopacity bs, myeas ); @ end, * Code in main.rn. + Impost < Foundalian / foundation “hy He impo @° Can h" int main C int cage , const char * ougvC) L @ autovicleas pool L Cork obit =[[ cot alloc] init]: Coby? Set@rand : @ “ Hundlai 3; Cobyi SekMode :@ “ito”; Cobyt Serfuel » @ * Peooi™); Covy1 Set color: @“ Red]; Cobjd SetCubic : 1086]; Cobyt Setscopacity: SJ]; - “742 7® /@ 7@ vd ° J) 4 Get Brand NS Log (@ 4@7@ /@7@ vd 7d, Coby ae Peat Get Cold Get Fuel J GebCubic J he Sepactig Car getory ear}; Co byl. stain 5 pane ee! Cas * obj9= CC Car abhor] init] ; Coy? Sel grand + @ “Hundai J; a —@*ia0" 7? fees) Sod + — @o Rel 05 —— © 21296"); . @:S3; Coke Usplaydata) ; Cobye sebainy; Setuin 0; $ % MulHlevel Inheritance * a Deriving ® clay Prom an existing detived clay is cated Mutfileval Inheritance. when We are working with muHlevel inhevtance then detived clan conjoins abi the functonality of eupactay & boleclot obo * Over ing % waitin a — muti ple Hme, with same name & diffrenr objects Is catled oveloading * Overridiing cig Reimplementaion of fore clay method into aubclos ts Catled Oversicling . > Generally when ee need fo provide ectending fancHon - ality of superclay methad io Subclass then secommen— ded to 9p fos overriching a By ing overtiding we can provide complete ned loshavions of supercla Method inte subclass & It is possible to extend new funcHonatses- > When we Moe extending the supercar mehnod IMto Subeloxs Yen muut be uequired to call Supetclass method Crom guoclai Co * Cacate a commandiine tool appl” evith name Clauksé. > Create O new Clay Colled Emp Subcla® of type nig Obj ect > Create @ neo clay called Faculty subclay of type Emp ® code in EMP-b t # impoat < Foundlabion | Foundation-h} @ interface EMP + Nsabyect bint émpta NSSti ge emp Names Shoat int emp Age; uraigned int empSols Float empPF: ~(void) getdate ; —Cvoid) Show Dabes @ end code in mpm A impos. EMP. bh” @ implementation ~ void) getOako emp chor. name [30]: NSlog (@" Ents ENP LO: "); Scant (r7d", BempTd) ; NSLog CE“ Erte Name: Scant (*7%S"named; empnlame=(Nsshring stalnglWiIhUTF8 String Name] NSlog (@" Enter age: ScantC* “pi "emp Age); Nstq C@ “Enter Salas: "); ScantC “ 20", Zemp su): Cen PF = CFlo at) emp&t /io: ~=Cvoid) Show Coba : NS Log (@“rDi 7d NAME: 27@. SOL3 7.U Age: ahi empla, erp Name, empSol emphge, empPP); 5 @ end ® Code in FACULTY hi 7 ae PR: yok +4 impoat “EMP. ne @ interface FACULTY: EMP 4 NSStri ng & FacSub; NSS Fang & Pac ull s NSs faing & fac Dept ; NSstamy ® facMebile ; 5 -(void) get Dako; —Woid) ShouDaba ; @end ® Code in FACULTY Mm 8- +H imposs FACULTY +b @ implementation FACULTY ~(void) get Pasa t Chor sub[20J; ches @quli £10); Char dept Cod; chai mobile Ceo]; Couper getDard) ; NSlog (@ “ Entor sub: "); ScanPO"% 5", sub); facSub = (rigs tating ising WithUTER String + Sub]; 7 Nisley C®“ Enter Gui >"), Scant CV. “i quli); FacQuillt = (nisg triig staing With OTFRSHYing QM We NSLog C@“ Enter Dept: “J: Stan! Cv." dept) ; Fac Dept=[Nestanng staiggiihUTFE String + deph]; Nstog (@~ Enter Mobile. 4), Scant C" 45" mobile); FreMobite = Cnssiaing Shigg With UTFR Shaing smobile’y; 4 — (Void) ShooData i [super Show Data) ; : PAHO cube % Guli: 7 bitg Pht hs, LfacSuy UrFEstriayl PUA Sub: % Bulis 7s Dep *imcaalt UrFES + [fac dept UTFRSteieg’], Ce Mobile uregstring)) J . J @end . * Code in main.m sy H lmpowk C founclation /Foundasion.hy # lempost ® Emp.b" H tempo © Faculty. Ink madn Cink cage , corgi char * angvl J) @ outoadlease poo) Empr obyd = CCEMP Aoc Jinit], Cobjt geDeday; Coby4 Show Date) ; FACULTY ¥ obj? > CE FACUTY aQloc jini]; Co's? getdate: Coby? Show Dato) > TFC Loby + istindo claw: Ceme @clau] ]==TRUE ) t NSLog C@*Ovyt tyee ts Emon): TE CE FACULTY isSubclayOe Clos: CNSOW;ect Sclau))==TRUE) NStoy C@"“FAcvITY Ag SubClay -of NS Object") s 5 Cobjt setoiny ; Coby? setainy ; j Athan Oo ; ie] i [Nsobject ] ‘ee SEmpid eo = > Emp dame > Bmp Age Ss suse 3 3 Emp sot > Emp Pt a0 ie of FACULTY |? Sub Pre 9 Auli o ae ou 7 OF] 10/2013, ¥ Rocedine fo overtide Neobyect methools in delved clauses # Create o commandline tool appl” with the name GBanilex: > Caeate a new clay with the dame GankAccount subclaw OF ype NsObject: > Caenke O new class with name Saving Account subclars ot type Bank Account % Code ta BankAccount-b s- eee # impoat < foundalion | Foundation +h >, @ interface BareActo use + Nsobyeet { long iqte actourtno ; dowdle account galance § @ pooperty Caead coasted tong int OccoundNe; @ property Crcadwaite) double accoun Balance; + CBankAccourte) aioe; + Cing no of ObjecLourd ; (Void display info @ end ount.m | * Code A inpoad eee eo BarUeA ccount hh” @ implementation Qonk Account @ synthaai ze accouryNo ; @ syntmarize actourt Balance; Stole Ink ObjectCoud= 0; + CBonkAccount * ) Alloc \n_GanteA ++ ObjectCouns ; aerwun( [Super atiocy); I nsobyect alloc + Cind) no of Object Couns { SUUAN objectCoun ; 5 —Cuoid) display Into * stag (®" cou No; ytd Bolance? %IF " accovtme, Accouy Bolance) - @ end * Code _in Saving Accourd-h 4E Imooat ¢fourclahion | foundation h> a Impoat ~gank Account." @ interface Sowing Account + BankAceoury ‘ Floats int Rate: T @ psopady Cacacosdte) Foal intfote - * CCavirg Accous x) alloc; ~ (void) Asplaytaty ; ~Cdouble) wie jateate ; @ end. * Gode_in Saving Account. on :- # Impaw “ Saving Account +h" @ implementation Saving Accouns @ synthasize intRabe ; + (saving Accourd ##) Akioc 1 setutn CCSupes attoc))} 5 (void) displayinto 1 NS Log (@" Account WO: %Jd Balancer /AF int Rote: fh | 5 account NO, ActcoutBalance, intRade); ~(double) calcint kate Beka CAaccou Bolagce « intRaie); 5 @ end # Code in _mainm * Socee man 4 Impoat ¢ Foundation / Foundation. h > +H tmpost ™ BankAccou -h” H impoat S Saving Account hn” int masnc ing cage, cont chad * osgv Cy ) @ awhoreleasepos! t wits GankNecourd * obj (f BackAccouns aulocJinit J; Coby4 ged Accoury nos 128456) 7 Lob, 1 serAccoud Balance : 3429.22); Coy Bs playTate] i Soving Accouns X Obj2 = LL saving Aceourt awot jini]; Cob, 2 setAccourd alo: 326 44 J; Coby 2 se Acoun Balance: Ay000)/ (ob) 0 settarevde . 0-026] Cob) 2 display Trt); NsLog(@" tnd Rade Amour : YF" [obj 2 Careiat Rosey); int Obj Count = Cone Accout novfObjectCounty ; NStog CO “objec Cound YA" Pobycount) / Coby 2 seeing: Cobjt sean); Adiurn 0; J 5 3 aorr~~ Nsobje ct init . >setoln . , i ree | aod So- L J BaneAcovat Noof obyeck Couns > 9 display into a co:Bos | , aWoce— ~* iohPake Soving Peart covint Rake ey 3 dise lay Tato. Bonk Aceouns x Obj 2{C BonkAccouw ottocd ining we 7 few pce nes, (CBankeAce atloc] Jose] nase Crisobjeck ated) Cobyt setpcenvo ; 123476] CT Objt settee.col - 1294, OW3 97 Saving Recs Ob) 2= [ (Saving alloc] mut] ; Uae LOB serneese spawn), POHL Caving Rees allt] i 0} : ene oo YL SEPACC Bal: S000 J - aes LC Garde. avoch, 1 SRR” Coby? stint Rove ; o.02f): 1 RKRfog? asptey mp, eC msenget alter] * Cantsolling Acces to instanse Vagiabler :- y By defautt imfonce vatiables in o clas can be accene A by methods of the clan This is the default behaviour of any clau- 3) Gy default any claw con containy tuee typer of ALCEM Controlling: Le %) Paoteched z- Accew iS otlowedd erty oy the methods of the clay & iy gubctayy a Acces is not avoilable fo Subclau ©) Public: Oisect acces available fo methods of the clau, Subcloy & Gde in anothet modille or claret 09 /10 /2013 Gahegoaies in Objective C 7 & wing Categoares it is Possilole tr ada neo methods to existing class in place witheus using subclasses (Inhesifance.) > To implement the categosies we ctoesnt sequise eushiy clan seleted -h& em File osb ek > Cate gosies can be sefer like clos extension also > A eabegosy con be cleclae for ony classes even if we don't having osiginal implementation source code. Buch of for standard cocoa ox cocoa fouch clawes- > Objective C categosier puovide the ability fo add Punctio- naity to an @bjech Without subclasing or changing tne actual okject > Genwally categovier aequisel to wie fo add the methods fo exithng clanes \ike NSS taing oa yourlout own Custom objects ado. Subclasing is one way fo add the funchonality to on object bal Ovoiding unneecedary fede subclauing by wing a cotegpay will hep to reduce the amount oF Code & Keep your paoject more oagonised, DTN Following cate always secommencked fo go for. categories 4) Extends ng an exiskag eecoa elay 2) Clow Eakension 3) Paivate methods on a claw * Syotox fp Create Categostel 2- @ interface ClaName CCategosy ) Dabo Membess ; Hemba functor : @end. > Alwoys categosy selatec intatace SecHon ghould -be esist within the neader Fler ony > Implementation section mut be enist within «m Mle onty @ implementosion Clay-Nome Cacategeay ) method code ® end. example ¢ Adding GetPata & show Noto metheds te NsObject . ? Catate o commanding fool appl” with name ar ext- > Add the new cotegosy fle to the project Steck Ble new—s File of type” Objec tive~c caegaxy* Give the Categoay name a1 ngobjecitston. & select Cotegoay on NSobject iu Code in NSobjectt nsobject Extend. HE impodk ¢ foundation | Foundation: h > Sebha jo bs-com @ interface nobject(ruovyect Exten) ~Cueid) gerala ; —(void) Show Data 5 Gena. % Code in Ngobject + Wobject Exten-m 3- poeoeoy Hhimposs ~ NSOb)eek + agovyecexien “my” @ implementation Nsobject Cryobjectxten) —Woid) getpata { iste (® From gekdobo”): -(void) showOaba i ; NuLeg (@ “ Hetlow Chow Dare”); @ end. * Code io _mosn-m t- 4 impoas ¢ foundation / Foundation +h} HY Impord CNsobject + nsobject Exten.h> ink modn Cint Age, conat # chauk, AgV TI) { @ autoselease poo | 1 NSobject* obj = CONSObject aoc) init]; Tob) gedaay; Cobss show Date); Coryd aetoin), 5 ASUL NO ¥ Ceobigg 9 culegosy® cuitoma claw. ® Caeote a commandline tool appl” with the name EmpCos > create O new clas with the name emp * cede in Emp-h % #H impoat < Poundahon | Foundation hy PS @ interface EMP: NSOb) ect t Shosy int EmpTas Ngstsieg # Emp Name ; uaigned ing eorpsed; @ propeaty Caeadwailedgnoat int Emre toy > @ property Ccopy Nssharnge Emp Namers @ property unsigned int EmpSal; @ end, me * Code in He mpoak “ENP: n” @ implementation EMO @ Synthouize Emprzd = _Empid/ @ synthasize EmpName = —Fmptiame. 3 @ gynthasize EmeSed ; ® ena Cacate nes * opjective -¢ Codegosy file with name EMPL EmpEvton calejosy of EMP Y * Code in ENP t+ Em Garten h. 5 #4 impoat “ Emp. h’ @ indorface Emp C Empfxten) § A —Cvoid) Show Data ; GD" cyoid } getdate :tinb)i withNlame; (nisstrieg &) Name withSals(Cunigned tatys; @ end % Code _in_Empt Emp Exton. m, = @ implementation Eme CEmpExtend (oid) gekDada +Cint)i withname: Crssiasng x) name withsat Cunsigned tnt )sy t EmoTd i Empname > name; j EmpSal = § 5 -Cvoid) Show Data t 5 @ end # Code in malarm % Slog C@"Y. hi YO LU", Emptd , Empname, Empsa); 4H impoat Cfoundation /Foundation-h? HB impogt © EMP +EmpExten +h > Ink mod Cink cage, Cont chawsa +, GV LJ) { @ auforeleasp ool q Erie x objid = CCOEMP adacjinity: Cobyt get Dato + loo with name '@ “Roy” with Sal: (BUTI, Cobjt showDaray ; j Cotyd weraing; 3 tetas to [10/2013 > When we are waaking with te cotegoaier ik obit atlouy Yo add the methods to enisHing clam only ive. it is not Possible tw add ony inutance vaticlble ts the categories: > Tn implementation if we sequiased imjance vasiable fo any extshing clauer then, ik must be AeQuised to go Poa Claw extenion- * Chay Extension §- > Clary extention is a similar concept to coteg ose with Mose powerk —Feahnres > When we ore Boe aking with claw extensten iF poill allow fo add nem inttance vatiables & methods fo Caish ng class > When we are taying fo add claw extenion fo Me Cussenk Pdoject then if will caeare *.h' Pile only. Cif it is categosy sh Rim will olto be eueatedf’) - 7 Claw extension must be sequised to add A Ceitem Clavier only fe. iF doesnt allow fod Cocoa’ elauer Ceategosies wll attows fox both type) When we axe cooanin WH Clala extension, must be aequased the implementation C category coer nt equisecl) > When we are mnt be pak of existing ehasg, Woaein with Clay Exteraton , methods implemented in Osiginad elau vetated «m file ony. Ceategosy isl ators within their Own om file) — %*& Syntax fo Carate Clan Extension @ interface clay.nName ¢) i Tnatance Variables metho \ @ end exo ples # Create a commandline fool appl” with the name Class Seb DAAA a neo class with Me namé called EMP, subclau of 4ype NSobject > Caeake o neo cloud Extertion fle with name NEWENP on EMP claw ® code M_ENPh t- cote Moenh #4 impoat < Foundation | Foundation: hy @ interface EMP: Nsobject shoat int etd; NISS taing & eName; unsigned inh 2Sal @ property Cagacsogite) shear int eta; @ property Ccopy) nisstarnge eName; @ propesty Creadeoaite) unsigned int ehal: Word) dssplay Data ; @ end * Code in EMO. m tH 44 tmpoak “ENP.” 4e impo.” EMP_NEENP. In” @ implementation emp. @ synthasize etd, CHA, eName epno; Cvoid) Se Daba ¢ Cink} with name: Crisshaing® name. andgal > Cunsignet inh) s evith Ano , Crigstrings) P t etd =i; enNames ame ; VSol-s ; epno =P; ~(void) Asplay Bata Nistog CO “E07 ¥-hi Name: %@ calz7u Ph:7%@ * etd ,enName, Sal epno)i Cend * Bode in EMP_NEWENP.h I Ht impos " EMP. hp” @ interface Emp Cc) f NSSfaiog # PTO; e@ Property Ccopy ) Nsshaing a epno, ~Cvoid) setOotka : Cint)i with Name. CNSString 4 Name andSal > Camigned iat} s with Pho Cnesiviga)e, @ end, 7 + ® de to mola.m t- ae A impoak ¢ Foundation / foundation. h > A \mpoak & EMP RR” ' 4S impoat @ EMe_ NEw ENA E ink made Cint oage , const char ® , aagy CI) @ ownselemepool tone Obyt = CLENP. atloc init’); Cobyd Set Palo: 122 Withniame: @ Rajesh” ancl Sal 1294 T t0 ith PnoDlooloor.eod] s Covyt display Data J; Cobjt setadny » ARUN ©; 5 x Protoce +> Protocol will provide seb of ceclatation at the methodls Which can be implemented by any Other eharses- 2 Th is Secommended fo go fod protocols when we ate Not ak providing Publ Fleged Pun cHonakity of any interfaces: Maximum of cocod setated UTKit 28 Frome Work hoving mutiple of pactocols those stequised fo Lael when we Be Wing ang OUT componenss like beatbox’, bultom , UT fable ox ods Other corJaoliess - > When we are Wostting with Psotocnls, we fo folio Hoe procedures ie ® Creating Q Protoco] @® Ala pling, the Protocol, ® Checking type OF psctocel. * Syntax fe Caeate a pao tocof i @ Protocol Prctocot-Nome > * Syntax fo Adept Protec} I~ \ equi sed @ interface NEW_CLASS + BASE CLASS Eprotocol name> declaration @end. *® Example’ Create Q commandline tool appl” with the name Pactocol Ex. Caeate A ned protocol fle with the wame ShieetLegal ** Code in Stace Legal-h :- # Impoak < Founckation | Foundakion. h> @ Protocor Shreetlegal ¢ ngobject > ~Wbid) signal stop ; “WOwS Signal Left Turn, “UIA ) Gig nad RiohET Un; @ end Cagake o Mew Clays with the name Cay.stbelay of NSObject ® Code in Car. Code io Corb + impoat < Foundation } Foundation:h> “H impoak “ StacetLegal-h” @ interface Car: Nsob ject Z Streeklegaly 5 ~Cvoid) cignol Stop ; (void) Signal Left Tun; —Cooid) Signad Right Tuan j @ end Code in Casem 3 te] Impoat “COL” @ implementation Cor: ~Lvoidl) Signal Stor t NSlog (@“ Cor ts Stop"); 5 — void) Signol LEER Tuin ¥ astag(@™ cat thos foken let} kun"): 3 (void) signal RightTusn L NS Log (@" Cor hay taken Light furn"); 5 eral ¢ Coeake A Kao cla with Name Bur subelau of Ngobject. c * Code in Bus-h f- # impost ¢ foundation / foundation. hy # lmpost € “ SheeetLegat: hn” @ jntortace Buys Nsobyect¢ Streetlegal > —(vold) signa) Stop : ~(Vord) signed Lett TAN? ~Woid) signal Right Tusa i @ end # Tmeoak * Bush” @ implementation Buy ~CVoid) Signo Stop : NSLog (@* Bua stop”); —(woid) signed Left Tuan “stag CO" Buy took lett) > ats signal Right Tara ielog C@" Bus took Right"); j @end. ~ F Code_in main. m i AE tenpodt < Poundation | Founclation-h > 3 impoat “ Bush” # tmoesd * cash” Ak mad Cin oage ,contt char & , agvta) @ antoseleaupool t iA myosy~ CCS atlocjinty; id CStscetleqad Sry oby = CC Bas alloc Jinit] Le CCmyow) is kind OF Clays [C48 Gor clay) ) i [ my ob) sig talStep3; Cry obj signal Left Tuang; Cony ob) Sig nou RightTuAn) ; cue TF CLmy obj is kindorCion: (evs cu}y) ga ee. Ceryory signalstop3 Crryoby Signa ett Tw); Leryory srgnad Right Tuan) ; Cory oby artesian) J ARAN O | 5 J U [lo] 2013 Duigates % Deligate is a genetic tyee of Objective-C which atlow to Communicate the date ber” the objects > when we sequise fo pars the data fiom one clara obj fo another claw oyject, then it mut be possible bg using detigotes only Deligater are implemented by using protoce \s only When we Ore Working With Cocoa UT conrollers then from one contool fo Another Conmol iF we scquisect te maut be Aeqiued bo vs commu Uicate the Gato then (ft Kenplement by wing detigater only * CSyntox te caeate O_deligate method 2~ @ protocol Celogabe Nome CNSObJect} Methods Declaration ; @ end. * Adopling the detegater fo the clautt- @ intoxface New_ctAss « GASE_CLASS 1A < Delegate Name > cluegates deelaraon @ Property Cnonatomic, atsign) id olelegate; end. * Calling fhe delegate method from some other object * @ interface nuPW_CLASS + BASE CLASS < Delegate Name» a j @ end for ey: Clow A __ Class B “@ polocol Addegate ome [ei soem ay =(woid) abe | @ interface claw 8: NJobject @ end | 1 cred) @ inderface clay A + Nsobjed + CL seth delegated abe] ; t : id CAdeegaleS daegake : 5 t | @end @ Properly Cnonatyevic, strong did deagate; Oncoond _ Process Statt LT %* Memosy Nanogen ek io Ob) ective-C i- >In Objective-C we having oo typed of memosy manag e- Merk 1-e. StaHe memosy alfocaHon & dynamic memary atlocaHon. 1) Stake memosy atlocation t- When we Ae Creal ng the memosy ot the Hme OF eompilation then it iS catled compile Hme Memory Management 6. static memosy allocation > Geneally fo opjecHve-C, doesn't rcquise fo go for Sloke memoay aUlocation P Dynamic Hemory Allocation ‘t- > when we are cack ag the memony at the Rme of exec” Men it is called Dyn&mic memeay otlecat” > To objective-C “nsputareleaterool” clatt te Serporn ble fox. dajnamic memosy auocation > In Objective-C Ay namre memory attiocaklon eoill handle log Acforence Coursing mechanism . *% Reterence Court 2 ae ea > This is objecHve-C memoay management technique which holds number of Counks which ig hooding by objec}. te. one object is hnoleling how many weference eae Count value — When we ase Avoraking the memosy fox, Any objec then QutomoHcally sefeenee court jc incuementedt by 4+ When we are Selearing the memoay then automa Caly AeFerence Count ayalue decal ae by t > wnanever one OO) seferenca count volue ig © C7020) then it is catted object is Cuce > when we aro USING the “seleque” method ,then ik wilt Aeadocare memosy for whe object & gsergrence Count Allo oleesease by 4. > when ve We Calling ~adiodn” method then memosy will Aentlocated fx the object bub aeference count astil Net decreage > when we Are tovaking with aubosdeasPool obj then always aecommended fy wie “dxain” methed only. pecaus é “dain” method will cau Jarboge collection system. 5 Gas bage collector Is a atttomatesl Procers whith ail! destooyed He appl” selabed Fremosy when the appl’ is terminated. > To place of cacating object of type nisAutoseteaiePoo! then always secommended to go for “@ autloseleas poo!” block. @ owe seles pool M Code beartiting fom a loca} auterelease pool. 5 > In place of holding the. aeference Coun manuotly & Aeatlocal 19 by using “release” os “etalon”, ibis Lecommendled fo go For ARC CAulo Reference Courviyy) > Aceoading to autosdleare method Count value ig rer. then destroyed. » uohenevel deference auttomaH Catly object wilt be > TF we requise fe make enable ARC, then go fox Sdect Project File, choose build SeHings & Jo te “APPLE” LIVM Gee Compiler 42 - language” @ choose Objective-C Puro Reference Count. CARC) Yer or No FRAMEWORKS 16 [+40/ 2013 A Fromenaak te a collechon of clauet, methods & Some protocols. . > In MAC os, we having mose than Jo frameworks 7 In implementation when we ore Besigning any Kind oF applicator then depending on the sequitement, Hak Sperific Framework sequired fo-impoat in the opel” * Procedure to Inpost a Frame coor in Appiicatinns 7- > Select “Project template” Ale , then choose “Beuld” phase > Under “Build” phase, go to ~ Linked Gincwy with Libsarfes" & dick on “Add” button, ® Common wig Frameoaks in 10s Appliakeny :- 1D YTKIt Pramedoxk CUTKIP framesorte) 2 > This Frametooak te avaslabte fod. QU 108 appl” fos. COcoa events POLK Prametoak- will provide all uses Tater face acdlated Components » +) Mop kit Pramevoouk CMap Kit Prameuoste) 2 Gy Using hie framewoak, Map selated event cao be handle . iMeludi ng Googte map servicer aljo. ~ 3) Mesege UL Promewoak ( Meuege UL Framework) 5 > By uging this framewoik , We Can psovide meyege J Maing a Services. 4) Addaem Book UE framedorie 5- (Addaers UL: Framesoorle) 3- > When we wequised to seplicate the funcHonatity of Adcreu Boole, then go for Adclrers Boolt UT framework. 5) Game Kit Fromeosle & (Game tit frametoore) $- a) Garning appl” seloked servicer are available in this Framerdoue €) 1Ad frameeoak ( iAd- frameworks ) 5- > By vaing this Framewoak we can provide advertise ments in is appt’ +) Coae Video romeo ak C CoreNidea. framedoase ') 2- ~ Gy using This framewoslke, we can puovide media Player seavicer 8) Cone Text Fromenork (CoreTexts Prameooste) i > by using this FramedoXk , we ean Provide Gap hicg Tro text 9) Emoge ilo framework ( Tmage LO. framesoak) i >? o& using thie Framewark , ue can madpwate the \mogea 1») fAssels Library Fromewoak (Assets ibsary. Frames oak) i 3 Gy using this Framewdoilk, we can interact with devicers _ Specific oper aHons. \) Core Graphics Framework (CoreGrophics. Pramedosl) $— ae By wing Ynis framewodle, we can Provide 20 graphies APL funckosnalites Mb the applications 12) Quatre Core. Framework ( Quath,Care. Pramemdor) 2° > This framenonak will psovide animaHon velabedt APL: \3) OpenGl ES Fameooak ( OpenGlEs, framosorle) - : > This Framadoak will provide graphics components : 19 Gaming apel’ 19) Core Puctto framework C Core Audio: frame wor'e Auuchio Toolbox. framen oate Audio Unit. Framewowe) 1 a By aging thig Prameweak, we can dUated functonalites- load audio services 18) Medio Player frame rsork ( MediaPlayer. Prameuodl) $~ > This framendoak can Play risent Kyper of fle format te) CP Nekwoste Framework Crfrekvoal Framed ogi) 3~ > BY usiog this Framewesk, we con handle. nemoaik ~ Stuvicg tie equering ORL & geiling serponce from YR. © NF) Cae Date romeo CCosre Data. framewowl) 2 > Gy using fis Fameaorte, we can handle database - Haough- Cose daka. '8) Cose Foundation Pramemark (Cate founclation. Pramenwe rk) 3~ - — > This frameooak will Provide “c’ bared func onalities Vike dotaly per, String aw monipulakiony, loops, gocket progre aming & Some other servicer which ate povided by obyeckve C. 18) Core Telephony flu t- (CaseTelephory »frameoort) 3~ > This g flo will provide cau sevice adlated informakion V8. Ca segistet opHon. 90) Event kit, Flw s- C event itik Framewosle) $- 2 By using thie Flu ue con handle Calender & alorm ag@oted APT Services 1) Corclocahion ff + CCose Location. Promawoal) 3- > %y wring this f]W we Can Find geogrophical location - CGPS). 29) SQtite Librawy t- > Gy using This Fro we can wooak with light weighted dalaboue in °C’ appl" Dinjective %* foundation Pramenwoak 3- > This framewosk usitl Paovide “C’ type paemitive datatypes adong with ovjective C galated , object tyre dota. DS when we ase eoosking with puemitive dabatypes of C Then, we Canth work on menege Pairing system le tr doen't ato to part mewege From one Vasiable to another vavable > When we are wWouking eoith ObjecHve ¢ appl”, hen every variable Wequiied fo communicake calhy Other vowobler, go we need object type data. like Nsnumbe, NSS Hing , NeAvray , NSDala ate. *® Mutoble 3- Whenever the object ts aLlow fo moctify He date. then it ls cated Mutable , TF doesnt allow fo modi Fy thea ibis caved Immujable. %® Numbeg Objects (NSNumber)s- > TH is a Psedetined cla which tr avai lable in Founclation fiw. >This clay selated Odject wilt aow to hotel any Einol ef ‘C’ premifive dato type * ex Cacate Commandline fool Opel” with name NS Numborey, H imposk < Foundation | Pounciation. h> int main (—) i @ awtoaeleas poo | L AisNumber *® choiNlum, % ghoakTat x UNsIg nedzat Nur ; chorNum: [NS Numba aumorWithChar: A’? Nislog C@" char value: 4c, Lehoanue chay Value] )/ Shosthat = [NSnum bar numberwith Shas : 135); NSloq (@" Shost Vabuet hi, [Shoat Tru shost Value) ) 3 UnaignedTarnum = CASNumber NueworlithUnaig nedrabs 6395? NSlog C@" undigned vatue + AU" Cunuigned Inknluen unygenedIar— “4 Coauty ee yalace])3 NSNumber int Value / VntNotue= (NgNumber numberWith Zt» lo] TF eCCinrvebue Compare : shoatTny] = = NGoudet Ascending ) L NStog C@" Ai 2 BY hi” Cig Vatue iotane J, Cohastd at 5 Short Value} » Che iF (LintNatue compare» shostTU= = NSoudles descencliag i NSLog (@* X71 > zhi", Cintolue tntVetue], Cehos trae Show Hiskue) t he if (LintNatue Compare : ShaykTay] = = NSdardwedgame q NSLog (@* AI == Zhi" LintValue iONeLue') Ochoa Trt short Vabhe]; § NSrlumber ¥€ Moat Num, x doubleNum ; Floadnum = [NS Number mum belith Coat | 123.459; ouwble Num =ENSNumbey Tum berWith Double + 123456 -1e 43k)» NSlog G" Floar vate: 16" CFley num Ploot Vaue] ); i. He + Loloblentum loawle Vatue J): ® REO NSNumbe Refaene HEN0 [2013 % dercaip tion I~ aera > when we are Calbing dlescaiption methed on A\S Number object, then it paints decaiption of daha in ne foam oF Staing » * StaingValue ic > when we call shringValue methed on niSolumbex objeat then if aekuang stesng type date %* Compare 3- > oy uring this method, we can compare two NsNumber object data: when we Are woalking with ‘compare’ method, then if Sets ~ EN SComparisonReruth Vabue > NsomparisonRerult value can be Nsardered Dacending od NsOadered Ascending Or NSOaderedSame * \squal To Number s- =e th wing this method we con compare hwo NS Number objects ‘bub this method aekuiry boolean data. ie YRs a1 NO ® NSStaing > Tt ts 0 poedefined clau Which tg available tn Frindechion Framewoale mae By euing Sting cla object we ain manipulate Sbaing type date mose obRelently \ pole: C by pe Staley will woaks With the hela of ASCTT code ted byte data. , Nsstaing will woals with the help of Unicode data ie 2 byter Vatue S When we axe Woking with NSStaing object then ib ts not Possible to change content. beccuue by defartt it is immutable “3 (henever We sequise to change staing content Anoughout the Program depends on Aequidemenk , yhen ge for NGMUfeble Stalag object * Caeate a Commanding toot appl” with the name Néthring Ee > cede in_malnmi- \mpoak C Foundation /Foundation:h> int moda ¢—) i @ outoseleaste pool NsStaing# stat = @* This is staing As NsStaing « S102; stad = [Nsshang Shain WD tring . Stati Nslog C@*stri:¥@", stat); NSbg (@* 6ha22 7.@", sta2); Shoat jak 4 ; A= Core lengths Nisteg C@* Length of Stang. / hi “4; WSSIMey «stage @" Ths is shang Br; 1 Sta3> LStd3. Staing ByAppendStsing + Stat]; stage LSin3 siting Gy Aecending Faamar : @* ig appeMding 1 @", hrf]: Nola CO” sts data: %@ 6443); NSStasag A Stak | SHAL=CWSShAing Starmgiaith Farmat @ GUM OF yd 4%d= vd" 10,90 jo 490); NSly (@ teat ghaing: 7 @" SA), NSig C@ “Lower Care. 7.@"! [Sf 4 "lowercase String J); NG Log C@ “uppercase: 7. ©", Csbad uppetcore Sting Ji char temp Coo] ; Stacry Champ, (stad UTF8SHring]); NSLEy (@* temp Sting 71s" temp); MSS fatng * tenp sta» fempsts = (Nsstaing Staing NOTRE Sig + teop]] » NSLog C@™ temp NEStng s 7. @" temp sta); TE C[ shat comparerstar) == Ns Osdeed same) { NSLog CB“ Both skaings are same‘), iF CESAL is FqualteStaing : sta) ==YEs) NS log (@ “Goth axe same"), 5 , Betut 0; L HW Coeating boo user defined method foa NGStaing class. - Te geveues¢taing & changeCase SD Catale a commandline feo! appl” with the name NisString Clou— Enhancement. =) Caeate a new obj. ¢ cotegoay clan with the Name String Revexse Staing RevOng. Cabegoay on NgS Teg. % Code in_Nisstaing + string Rev Cag ch $- # Imposk foundation | foundalen.h> @ interlace Nsstaing Cstatrg Reveng ) FCNSStalng) Stang poverte t CNSSHAingK) temp: ~CASSt33 ry) Sting Change Cone; @ end * Code in Nsstaing + Stsing RevCngem o- 3 impoat “NSS fasng + Staing ReuCng sh” @ tmplementation Nestaing Coiarng RevCng ) HNSStAI YH) Stain Reverse « CNSSIIAg *)e-tenp Chas # Pa = NULL j Chay th; AEN Le Cin) Ltemp length); Pla= Cchare) cattoe (1, Size of C chat)); Stacpy CPtaCleme uTrEstai y J); for Cieos Jedioe The) f ch. etalid; Praci) = etald-i-s), ets (A-i-tJ> ch; Nis Sting # xeuur= CNSStAIng Shaing WH UTER Shing + PRD: 3 J Sey 7 free Ptads Pho MULLG defuin result; q ~ Crisstaing® ) Stang change Case . Char € Pha = NOLL? iny Tod; A= Cink) (sel leagthd: Pha =Ccharx) catloc C1, Size oF (chat) Ne Stacey Cpta,Csell UrpRstaing J); foo Ci -o;i Ca tHE) TECPILCIT SEARS PG Y= 2") Pha Cid: Pra Cita; Clse iF COLE) =‘ RS PHA Ci] C= 82") PHACIT= pha Li]-ge; 5 SUF = [Nsshaj 9 Stai ng edule PLL, face Cela); PhO = NULL} Aekuen self ; 5 Ww @ end © Code 1A main. +e Impost ¢ Foundation /Foundation. h> H hmpoad “NsStalng + staing Red Cng : int main C—) i @ arose ease poo! { NisStainge O6yt = @™ WelCome” ; NsStourg Obye = Erisstaing Sting Revere, obj 2] ; NSLog (@ pains Reverse + 7, @" Sbj2); NSStaing ¥ obj3 = @™ Hetlo Teri" obj = [obj3 Stab ng ChargeCayey Nsloy (@™ sisting data 27-8 "| obj 3); Adu o; § WV frol2o13_ ¥ Ex: with nismub # Impost < foundation / Foundation +h? tak moin C—) A @ asrtoseleas pool i Nesting Ghat = @* This is Ctaing AYG Nisstaing # Search , xseplace, Nstutoblestaios MV; Nsange Gubsha ; mata.c[ristabables txing Sting With String + Sts]; Ns ye" ; log (ave get) s tte Oo Find chang iAg-g" Coaha inserting @* mutable" at Index : 7] ; NSug (CQ. O", mba); NSStringa SAD = @ “and Staing 6": Leute jouentstaing » stas abZoder: Cuba lengthy J; Ning LO“ 7", mata); Crrata appendstiing :@* & Siving ¢*}) NSlog (@"v.@" muta)s Corsja, deleheChaseete, Tn Range : NoMakeRange (16,13) J; Nstog (@" 7.@") muta) ; Substa = Coutr sangedf Staing + +@" staing g and «7, NSlog CZ Iu x 1a) SubStA- location, subst, \eng th): if Coubsta. location! = NSNot Fo und) Cm delelechaie chest Range : Substay - NSlog (@*7.®", mata)? Coss sepaceChaedetsZ0 Forge: sate daage (2,2) withing, @"a mutable staiog’] ; o: Nslog (@"7.@", muray ; Search = @" This \s" ; aeplace = @" An example of"; c Subsha = Coke gongeOF Sting + Search] ; WFC substa-locotion | = NSAlot Found 9) Ceuta aeplaceCharcctors Tegange » substa“withSteing : tep lace] ; NSloy CO" %8", makad; 5 Seorth=@ ~a*> seplaces @y "> Subst = Cm ty vangeot String ; Seaschy : while Csubsta. location | = Ngalot Found} t (mata aeplace CharectorsTn Range subste withString: replace), Ste Sta = Cala, dangeot Sh8ing 2 Satehy - 5 NSlog B~Z @" rata’; SUL 0; % Nsstwing Exo * H \mpoat ¢ foundation (Foundation. ) ink main (—) - é @ autareteasrpoo! i nisstasng ¥ Stal = @'thig is shang A NSS falng % 2; NsRange subRange; sey 2 CStad Subs tsingToInder + J: NSloy C@*Cras From Inder G of grat: %@" sas AGM E(stat. Suubbstaing Faom Indes -G') carte NS Log C@ "Char Prom index S be stats 7-@" ger): sey= ((Sta2 SubsivingPromTnd ex: p'] Substring To Tadez +63); NsLlog C@*chas from inder g trough Ys 7O": 24), =DAN_eoay way todo the game s- AM= (Shar Stlbs 33 ng Ui th Range NS Make Pang eC 6) J; NS1og (@" achat from index ge Huough 13: yO" sey )) Sub Range = (shyt aange OFStai ng +@ ™ staing a" J ; NSLog C@ Nndex ydu, length ts 7 u ” sub Rang. locahon , Sub Range. length): SubRange= (tat range OF Siding: @ “Staing 2] ; 'F CgubRange. location = = NS Not Found! } NSleg C@" Staing No} Round); ee NSLog (@" (dex /-[u, length % Ju, sub Range, location, Stu Range \ength) 5 achun oO; Paedetined stauckue which is available 19 Foundation Pramemwoule > By ualog Anis shaucture, we can Find range ofa Substaing : ~~ Range is a combination of two NsUInteger values Bie location and length. > When we are Finding the substring From given Stalag Tf ik is noF occette then locabior, Value ig N&Not found. ” > NsnotFound equivelent votue ig “NsTntegar Max” value. * Common meth _of_N ing Clow $- Y) ShAing WithSkaing 3 > By using this method , we can cacate a Sting object orth another shiiqg contenk. (clays method) 2) length ; - > Gy using tric method, we can find length of a shsing 3) staing B: Aepencling Siaing 3 > by wing this method, we Can append a Stoing fo another ing > Staing appending teats Jaker place al the ond of the Cusnent staing only. b) Staing Withfoamed $~ Th isa clas method which is ued to cucate a sting Cb] \n ceratomized foamal Cuser defined format String data’) 5) staiog By Appendiing faamat 2- > By using this methodol, 2 can append -cuutomized string formar data. to existing staing. 6) lowercase Shing in > Tis method wit conver -currert string content (0 [ouret case fosmab 4) wWppercare Shair > This methdd will cnvett, Cue at Shing, dako in Uppercase 8) Sting WIMUTPE SHRI t- > Ir ig @ clay method hich {s wed to cacake NSSting obj faom *C' tyee stsing - Y> This metho will convert, AscTT cocted staing bo Unicooled shaing. Cibyle to Dbytes) 3) UTFRShaing 7 > This method wo ls used to convert uniode shai fo C type shang CNsstring to chat* )2b t tb) le) isEquod ToStaing 3 - > This method is used to compare doth Strings 7 BE same ov not. : > Tis method geturnt boolean Nolue Le. YES oa No. 1) Compate 3~ 53 By using this methed, we ean compare 2 shaings. > Compare method artur, NStompaaigon Result Volue- > NSComparison ResulF Value con be NCAsodeted Ascending. Oa, NeOadered Same 6.4 Nsosdesed Descending 12) Sutbstsigg To Index $~ > By using this method, we can exfract Me Substal yp upto given location 13) Substring Raom Index 3- > By wing this method , we Can ekract The Subshsing fiom given locating ta end of tre sting say Substal ag WithRange. i— ac, By ualeg this method , We Can extract the Supspring. In specie aange — > When we oe suing this method, we vequiae to Pod Nsange value Le. location, length. VS) sargeOF Shaing > This method will aeturn sabstaing range in the foam of Ng Ponge date f-e- location & \ength * Common Method en _ MgMutoble-Shai ng 2~ 2) Stang wWirhStsing 2 —> By using this clas method we aan eaeate NSNutable~ Sraing object %) AnsearStaing }- > By using this method we can jue a Shimg fo mutable Staing dota —> When we are tasing thie Methad, we vequired to Part index value, 1f we are \uesting at ending pos® then index mart be length of the staing 3) append Staiig s- > By Using this methodl, we can Append the sfaing ab end of the stsing alata. 4) delet eChasectevitn Range -— ~ by using this method, woe Can Adeke mutable String content in gpecihe aange > when wa are using thig methed., w@ srequiae to pas Ns Range veeltee- > NsRange vatue Can be parted by us} MY NsMake Range function. y (De lo(sels 5) aeplaceCharecterTa Chang e2- ee > By using this method, we can replace the charecter in speci be s0.0ge. > When we mre Wing His methed we sequiue to pad NSRange Value te. locaton & length, % Nshroy > Tris a Paedefned Clay whith is Available in foundalon Framewosk, by wing His cla object we can shore any kind of list of objects: ~ NsAayay is a dynamic data chauekue which can manog e number of elemenkk ar auahme * Fx: Create a commandline appl’ with name Ns Assay Ex. s- # Code _in_moin 4& impoak < Foundakion [ Foundation h > int moso C-—) 4 @oawr seleas poo! ne Aagay ® appledbjects = [LNs Atay attoc] init irr ory ecks: . @apote’, @°Mac", @” iphone” iPad”, @" iPad” @ ios; nil]: fox Cinr iso; i ¢ [appleObjeck count]; i++) t : / . NS Log (@" index :y. i. Objecs 1 Y@ , Cappleotjects object ArIndex:i]) 5 Capple Object aeleae) seluin 05 } ~> When we are woalting with NSAaay seloted clau object we can't update elements because tf 4S Q immutable - > At the Hme of execution of appl’ if we sequined to update the data then go for NsNutobleAsay class. * Common Methods oF NeAsay class 3 1) Initwi th Objects 2— > This method will ctlouws fe excate NsAssey From any other \ist of Asiay elements. 2) @_initwWith Assay s- > Ths method will allow to create new astay object from existing roy. OF File +- 3) InitWitnConte ae 3 By using this method, we can load astay clata Gram File. &) init With Gotents OF URLS - eee > Gy using this methed oe can Cucate [tet of ailay element From NSURL 5) anray withContent OF file -— > ibis a claw method which allow fo cueate the amy ehements — From file. 6) assaywithContents @FURL : - ee anal 5 Gy wulag this claw. metheck poe con load aay elements fom Neva. a) aay Wi thobjects # => ey using Pris claw method, we Can Cacate ict of auay ehemens 8) count s- — Th actu number Of atements count wnich is available tn cument astay objeeh. 9) Diiject At Tacken —> By using His method, we ean extract the elements with Yne heto of index > When we ase wing this method, index value muut be within the sange only, out of range if we are Given then pel” will erath. * NS5Mutoble fer 4H impoat < foundation] Foun dak on. h > int moin C—> @ awoxeleart pool t Ns Mutable Asray x appleobjects = CENSMubable Aare attoc] init WithObwectr : @* Apple", @ "Mac" @ iPhone”, @™ iPad", @* iPod® nig ; foaCint 120; 1 <(agpleObyect coun) , i rt) 4 asag C@inder :7.4 Objeck? +O" Coprledpyeck object Podex: iJ); CopPledn) ects semove All Objects] 5 Slog (*@* Count ; ¥ bi." [oppleObjects county), CappleOvjech add object : @* Apple’) ; CoppleObject add object: @* Mac 08x]; Coprleabject addobject : @* Nac Mini"), NSlog (@ “Asay Objects : 4G", appledbject),’ Coppte Onjects semove LarbObyjet]_; NSlog (@* Array Okjerls: 7. @" appleOkjeaty) ; CaprleObjecy insetkObject : SFOS" of Tndex zo], Copeledbvjects inrerObjecr > @"“ iPhone at Index: Copple obects count] J NSiag (O° List, 7. @ appleD ject ) ; Cappedbjecty Semovedbyect : @ “i Phone’ J. NSlog (@ “Listin @ "appleOby ec) Capele byes semovedhject At Tnoler s al, Nslog C@" lish? 2") apple Object) ; Coppreobject selease}; AULN O; § 2 2o/Jo/2013 Co coa _— — Cocoo. is an appl” environment for both OS% & 10S- —? Cocoa is a set of object caianted fromederks, Hbraries ‘ that Provider & Audtime envidonment for appl” eohich is Saran ng in OSX & iOS : . = Cocoa ts 0 Permenart appl" development enviaoament for Mac Osx & 10S : — Coa \s a combinohen Foundation, Apekit, UZKiF Frameworles > In OSX, Cocoa ig used with the help of founcdalton & Apokit classes 7? Tn i0S, cocoa is urecl with the help of foundation & ULRIF clases —P In both type oF opesating system , Cocoa coil provide . Graphical User Loterface CGUF) > We Cannot develope ony cocoa Opel without Usiog: Aeektt closer in Osx. +> We cannot develope any Cocoa appl withour wring UTKIt clases in ios. ~ Cocoa will Provide event driven architecture fox OSX appl” —> Cocoa will provide Mve aschitechue for iQ6 appl” 7 Cocea Aachijecture fos OS X User Expesience, ‘WDorhboad | [Soohighr] [Accesebiy] ee ~ Applicasion Fromemorks _ } if {Cathen| Tava cone Framecdork$ a Gaophics & Media " Ceolicalton Sexvicer) | [Cae Animakion| [Coxe Tmage | [@xe Video) [a@uick Time} [operat] * [Cone Adie) Cose Seavices [eatbon Coxe] Louch Sexvices} [Case foundotion] [Pesadeer] ee econ een \ a Core frame ‘Werk. ~ — % To 0X, Cocoa hoving two main parts Catled Application Sewvicer & Core services — Apel servicer will paovide UZ, App Framewoak., GUL& media Seaice’ for applicakon — Cose services will provide System elated procers. * Apekit t- —> Ty provider owject $ appt” display with UT & event handling paocen alto a Foundation t- Ae se Seu te > Tt ls a cose Services layer which paemitve Aataby pes , collecHons & operating sys fem seayices: Provider objett for # Coae foundakon s- — Many clayer Foundation framenmoal Will weak on Coue Foundation layer: ¥€ Carbon Core 3- —> This part provides any Kind of System services \ike, process, File Systems or Any ofher System level programisg % Cose Graphics i- — > The Cocoa rowing & image selated Claes cali worles voith the ‘nelp of cove qaaphics which provides animations 2D seated groplics 2 Wirdows services 3 Lone sevice im > To get the ike & ape? selaked documents to the ape’. we need fo use launch servicer — >» Cocoa is commonty seferred for combinahon, Apert Mac 2 OS¥% appl? framedoskes & it ig used fo develope (coo Touch aS — Gocoo touch is A utex Trderface Is provided by Apple fos cerigning naHve apel” of iPhone, iPad, iPod fouch. “> Tr is devetoped in ObjecHwe ¢ Jang wage . boued Pramenoak which on Nac Os. > Cocoa touch tit > Cocoa fouth ig a combinaken of Poundaton & ULE faamemorts which te eed to develope iOS follow MVC aachitectuter opel” Cocoa Touch. Aachitecture fox iOS \ Aeelicakon _ Cocoa Touch - Core Services ee * Coase 08 3- —> This layer contains the kernel, file system, nekoostetry infgatauchut, security , PoweL management & N aumber ef device clivers * Cose Services $= —> This Faameoesk will provide core services like Shing Manipdosion, collecHom , nekoosking, URL ublites » contacts Management & Paeference # Media t~ — This layer provider gaaphier & multimedia services fo cocoa fouch including Coae Gsophics , Core text OpenGl, core animations, BN foundation, coue Qudia, & Nideo player services ” Coxe Touch. 8- => The Framewoak jn this layer, diaectly supports appl” based {OS Peakues including Gometit, MopRi . Q Rd # UT UIKit + on >This Paamenseale will paoyides the objects & ape!” splay atong with UL R event handling Process : # Foundokon i- > This Pramaooale ill provide object, premiHue dataty- Pd, collecHon , OS services & ibis a port of ose Foundation Paamed ork — > AppKit aeloted some ef the functionatites may nor Pe Avoilable in UIKit 4 UTKit setated funchonalstel may not be available in Appkit. Model View Controller, CM¥C) > MVC is @ Aksign Pattern tohich Ossigns Huee sules for any kind of appl” ie. © mode ® View © Con facies. - Ls This pattern deflaet not Onty the Sues. iF defines the. way of communicating the objects with another Objects. ~> Each of tee type of Object is separated from others by okstrocting & Communicating with objeths across the ape!” > The basic ded advontoge of Muc daign Is appl” eatensiority with other appl’ > Many of technologies inc lucting Oschifectuser axe des\gned bared on Mv ony = As a programmer it ts out sey ponsibility fo derign cughom objects with the help of Mvc aachiteckiue- Cocoa Frameooaks & Muc Aschiteckue Contsolley Root View Controller} @) \00P | 1» (iwc) view QU objec Additonal Contwoller Objects Ceustom) 4 Model Objects t- > Modd objects encapsulate the data specite to an appl’ Gnd Provide set of logre fox paccesing the data. > A model objett Should have no explicit connecHon to the view object that paerenis its data & abtoce to user edit the date x View Objecks —> This object ony vistble be end user. > Fox any Kind of uset acHon view Objects oly rer ponelt > The baric purpose of iad object is display fhe data which jg available in model objet & allow fo edit the Infoamation by user iF iF Is deg ulsed - ® Contdoller. Objeck ¢- — Controller object will perfoum, How the, model ts Psercated fo the view > Communicaking : DA contretter object is intesmediate bei? mut ple. View objects & model object > The controller orty Ses porsi ble fox changing the model ogject data ox changing the view object date along with Cosnes ponding. Medel Q view Objet > vohen the view tg. updated then confaoller coill fakes the action to updole the made object, when- Model Object tg changed then controller eit: take the ackion 4p w View to update, c 21/10/9013 % Window based Applicahow in iOS os Single vied Applicahons > Cagate @ Vem {08 appl” oF byge single view with the name window Apet - > Derelect autoseference count & Stoay board optons: H Code in viewCortsoilerh :- # impoak CUT KIE] UEKiFhD @ interface View Controller + UrVieoCentroller Urlable * View Lables Ur Button % ViewButten ; 3 @ property Crom atomic, sebain) ULlablex view loble/ @ property Cnon atomic, detain) Ul butfon x view Baton 7 —(void) ButtonClick ; C@ end R Cocke in View Contuoller. mo- @ imlementotion View tontroties-h @S cynthosire view lable, viewRutton ; *€ code in ViedDidioad method :- Couper, View Did Load J ; Viewloble = [LT Utlable atloc] iniyusits faame : CAaRectNake C 20,60 1200 60) ] arutorelearp) ; {viewloble setText : @“ lable Text here] » CView tae ser Backiground Coles * (Urcolor clear Coles], Ceel. view add Subviesd + View lobley; ‘ View Buttons (( VIButtos burton With Type: Ur Gutton Type Rounded Rect] auloseense] * [view Button getfPaame +04 RectHoke C&O, 120,80, 43) ae (ViewButon setfitle: @ click met BuStates Uz@qt ro\stake Nx mal), (Viewtutton add Targa «Self dation: Oselecka Coutoncitek) fos Con biol Evers: UIcontrolEy ent Touch UP Tnsided; CsAlf. view addlsubvien: View Cutten] . $ | Ovid) Guttonclicle i TEC Evietwlabie” tert] is Equal Tostring : @ Butlon clicked Je lks 1 . Viewlable-texte@ lable text here": 3 ebse Cview lable’ sekoxt : @"Qubon Chicked J. ' f ~ 22/10/2013 * @ clau:- a. > Gy using this Preproceuiar diseclive we can ptovide fauord declasction of any other classer without uaing inhesi tance. > Tn implementation when we aequised fo cueate a object oF o clo in another cla without using inher tance hen Secommended fo go for “@ clan’, > UTR ponder class will provide event handling process log using User action => UE A pplicabion Delegate is Q prolocol which allows to leplemertt app life eycle Aetated methoal ~? AppDdegate is a current application delegate clots cohich ig inherited Prom UTRe ponder & UzApplicalon. — A view is a visual objects That Cxeater Wer interface of an ios appl” _—> Views are define: within the gpecifre sectangle crea of O Seaeen. — All views are subclaues af UTKit, VIVID classes > UIWindow claw Paovider the surface 0 gcreen which alow to add view components fo dis play — Tn any kind of 108 appi" only one UrwWinclod onject ig Nad lable ~> We cannot place any kind oF Utenntiolley, oacetly 09 Uzi ndoro- —> UIWindow must be Rit eine gcacen of the device. PP ULViuo class provicles model UL fox displaying the Content Vien. — tew-Contaotks. clay is Q Subclay of UrViewdController which Wows fe add any type of UTConMolter- — AppPelegate is a subclau of Uz Responder which atous to handle surface And App Iife cycle event % 10S App LifeCycle t- — App lifecycle even ose available tn App Detegate-m Cle. —> when we are lau ching the appl” Pisat Hme, Hen . Control will Goed Application: did Finteh Launching Wilh Open method: —> This method will called ory ence when we staiht the appl” Pastime > AN appl” adioted iniHalization mut ‘be fake place. within this method onty- — > The next method is called causing the appl® launch 2." Application Did Became Ackve” Cif URL ts not pierent) — This method may be cated mubttiole Hmes. > TF the URL is available then conhiel will enter into OpenURL o2 handleOpenuRt method, fuom here Contac] will goed fo ™ Application Did Became Active" method: POLO te Dd. re Pi esi —> After Appliccuion DidBecameActive mode ¢Conhol will goes to Appli cotton WiNEnterforegaound method Fo. handling UT event —? when user hits Home button os any intenupHon ocews Usmg Phone collg o4 meyeges then eonhrol will goo bo Appcakonwill ReignAcHve methoel Jn this method only we sequised to patue appl” ddlated forks if any thing is in aunning Stoku - — Faom Rearign Achve Method conta! will goe to Splice onDid Enter Background metinod., this method can hold only for S gees., so if we sequised Mose Hhan this Kme, then we sequidred to handle * agin BackGround Tasicwdi th Explaakion Handiex” metinod. — when the app)” entess inte backguound if Me memosy is not available then appl” can be terminabed by OS — When we double fal the Home button then appl” will be adaunechd:, when we ase selaunehing the appl® the combsol will enter ito Fosegaoundl method, faorm thease OpeNURL od applicationDid Became AcHve wnethocl will coll —> Whenever them appl” ig fetmi nating Hen, apolicatiat- Terminate method will call. —> Whenever app having memory seiotel problem then application Did ReceiveMemosyWaining method @ill cated. > Ta implemenfahtion when use que wodlcing With Pash Mo Acaten services then we acquise fo handle’ following - method & Applicaton : did ReceiveRemoteNiok Heaton k oppticaton: cid Receive Local Not cation. owes Oe, |abo Qutton UTGuston < ULtoatrer UrEViewtontroler ~s View tontrollet Ulwindew ——s winlow Pratl Vid nes aac —— - ~ & Caente a Sage wind Appl” yodet 10S cabegory with . the Name udindow APP? far dewice iphone > when we are wosking with empty appl only App Delegate clos vill be cot hauucted, > Add a new ctows fle with the name fisstView Controller ~ with -xib file- — vohen we eseate a nao clau then attlomal Hue Filer are Creaked vie Fastviewd Controller. h , asviewGntealler-m Draseview Con hyo tier x1 * Code in AppDelegate.h t- # impos CUrKIE/ UZKIEN> PS clay Fisst ViewContyolla - @ interfere AppDelegase, UtResponder C UrAeplicakon Delegato?. @ Property Cshaong nonasomic’) Ur Window & Window ; © Property CStrong -Monakomic) FiasivianLorivollay view Controller @ end R Code in \peDelegae.m :— Himpoat € Cast uiowlontrotier. bh’ + ~Cvoid) deatioe ; [_viewoContro iter ueleaue J; $ Add Finish Launching With Option SELF. View Contro\ter =CC FiastView Controller aUor} init WithArh - Name + @" FisgtViewCon holley bundle: wily, Sel. window ‘Loot Wew Con frotleg = Sele View@onfrallers § K Code ia KashView Con tuotler h o> 23/10/2013 CAA 2S elee3 @ interface fissrVeotontroller : ULVienConpsrotter 1 j @ property (nonatomic, selain) UTLable& lable - @ property Cronatvmic , xetadn} U7 Button * nextButron y —(ooid) next Guttonclicleeal + @ end =) create a new viewlonhioller te the pagjeet voto Hoe Nome SecondViesContucller without oxi hele. ¥€ Code in Figst ViewConbolter-m ¢- ee # Impoak Fiat View Con ro ilet-n” # Imeoat * Second View Controller -W" @ {akerface FisatViewCon bella 0) @ end. @ tenplementation Part ViewControlier © synthasize lavte . next Guion; * Code in view Did load method :~ t Csuper ViewDid Load ; Cope véend tack qaquad Coto : Curdejer greenClos 17+ labels [CUZ Iabe otLor’) init With Frame: COReck Malte (40,20, 200,08) |5 Llobel. setTert: @° View 4"): Clobel SerBackgsound Coles : CU TColay gray Coles) J; Claber gerText olor »CUTCOla bluetoloa] J; Clole sttTert pignment > NS TextAlignmn ery Cen Fea); Coe. view Dddgabuieo : (abel J; NextGutor= (UTButton putt onWithTy pe : LUTGuMon Ty peRoundRect] + Crext Button Setframe : CaRectMoke( 40,200, 60,40) J; Crext Button settiHe: @ “Wed? foaState : UrControl $ fake Nak mal], (nexrGution SerTitle Colon + CUFColox red Colas] for State + Us Gntrolstate Hightig hteol’]; Cree Qutlon addTeuget; self acton: @ Select or Cneetbubion Clicleedy foa Control Everdy + UE Control Event Touch Ue Iuide] ; Csefevier addSubuiew ; nettButorty : = (void NEUBUtion Clicked Second Viewlon troller ¥ next View= ([SecondViewCon fro ver oblec] iiFWithNbName: nil louadle: oily; CSUF. view addSubView: nextWiaw «view ; 5 ~ (oid) deattoc q Clable seieaye) ; CrextGution seleos 0); Couper dealoc); H impost C Orit /UFKIEh? @ interlace SemndVieW Controller : ULView Cont acta a J @ property Cnontutomic stain) UTIpbels Lobel » U1 Button % Neu Outen, Urutton x back Button ; i —Woid next Duttenchicled — (Void) acl GuttonClicked ; @end, 2 Add @ new ViewdConysoller to the puofeot with me name HiadView Contsoller Without -xib Mle HX Code in Secon dvi ao Con tro ler eee OS H Impoat * Second ViedCon tro lieth" ey IMpoat “ Midd Vi aw Controller h” @ synthasize lowes peckutton, Nextutton * code _in ViewDid Load mi CSuper View Did load J; Csetf views setBact gsound Golan: CUIColar ved cota)); Jabeh = CC Urabe attec] init with Framer CO Ree Make (4,30, 200i, Chabel cerfexk | @* View?"); Clober SF Bock ga und Eoior ;(UTColoa green@ lou} J; SC late sek Tent Color : [u2Cels white cot Jy,; (Close SetTexthligamedt ; NSTeupti gn mens Canter]: Coert. view addSubvias : label ; back Budon: CUT Button button With Type : U Taton Rype Round Rect], CoackButton setframe: Cakeci Make Cho, 200,60, 40) J: Cote ution sekTitle: @° Book” RuStale + UrContyolStore Nermety. ChackBution sekTitlecotos :C UzCola 2edcole ] for State : UTpCorts0|Staberiy lighted J; CroackGution addforger Ser acHon 1 @ SetecgC back BatfonElicleed) PorContarol Eveaks + UECon trol Ev ear Touch Up Inside y, Coetf. view adaSgnvian: back Butt or); New Sution= [ULBution button with Type : UT Bulson Ty pe Round Reel) [necputton get from: £ C&RectMake (IS0,200, 60, 0) J ; CerextQuton seiTitle » @ "New" for Stole | UTConto( State Nov mas] ; CrextQutton gefTitle Cola + CUECola sed Color] fou State UL Conteot Stale High lig Wied ; Crew guton add Target : self action: @ Selectos Coerh Button CWcleeat) Fo Comyo Kyenty. Us Cont! Every Touch Up Fuide J; Cah. view add Sub view: nett Button]; Cold nerd Gettton Click ool “Thiad View Controller * Met View= L(ThitdView Conteolter aoc] INIT WitHMdie Name tail bundle: UI); Tsere. view addgub view: next View View’) 5 —CVoid) backGut onclictees Cgelé. View semove From&upewi eo}. 3 —CVoid Jdeauoc t ( Nobel seleaye] ; Crrext Guten sclewey; CoackButton selene ; (super deatlec J; —— > deatecatest last alwoy49, supe clay Objects. @ end * code jn Thisd View Contsoliessh 2” H (mpoat CUTIE) UT IIE WD. @ interface ThucdView Controller | UzviewContreller t 5 @ Property Cnonatonuic, uwelasn) Ullabel x fobet a UiBubloo A out Button ; OT Butt on * test Button ; ae ¢, (oid) exiutonchicked -; —CNoid) pack atone \cleed ; @ end, ¥ Code in ThisdVjewCootrotler:m 2 @S gynthasize label, exit Gut on, a ckQation, Cselfview serBaotegsoundColas + CUzcoloa yeou Cow), label (CUTLabel alloc JinitWith From: CaRect Make CVO, 30,200, 3), Llaber gertent, @“ view?"J; Clabel ser packgaound Colm > CULC}oared Colas] J; C robe setTexkcolar: CULCla black colo] J; Chobe serText Alignment > NsText Align entcentery ; Cgett view addSubview + lobery, pack Qut on © (UT Que on pubfonw ith ty ag Uz BuHonTy pe Rounded Rect, a Same os Paevious Packbutton ade : exi tBu tions [U2Gu tion buidonuaitnTy pe? UTDu HontyreRoundledl Rect] , Cexit Baton serframe: Ca Reet Mote (1©, 200, 60, 481); CeritButlon seme: © Exit” FurState UxCentrolictate normed 9. CexitRuton S&HeMla:(UIColor sed Color} fos Stote + Ut Control Exetkictabe Hightighted J, CexitQuton addTasgd: sele acon; @ Selec tos (exit Buddon Clictes ) fertontrottven foxStalesdEtyntret state fou Control Events » UsContyol EveruTouch Up Frit ide); Cseyiew add Subviaw: Gut Butt on J; — Luni) ode Bu tootlict ed 4 Cself- view 2emovefrom Super view]; oi —CV0id) exit Buttoneliciced aul Cod; -(roid ) deatloc Clobel seleared; CexitQuton select]; Clack Button seleare), Couper deattoe J ; —— Kox } NEFViC] je Gocelegrund View give iPhone \ehore 3 & 996 xugo 3as 4 4s I t rox S69 85 % Caeate a jo$ appl” with the name Windowhee3 of e y mety ape 24] 10 J 92013 = Create objective C clawes with the name HomeViewContr- ONeL, NITV lew Conkao lier, 105 View Controllez & iphone View - Contsoller: = Cacate 4 Png images with 320x460 Size. caith the name iPhone. png / NIT. Png , Home. png , iOS-Png- = Daag thee all 4 png files into project lemplate o& add fo the Pacject. D Caeate another 3 baton Images with [ooxioo sizes with ‘he name buxtond-png , button’: png , button: pag. Anel clap 03 add to the current project * Code in App Delegate-h :- impost CUTKiF J ULKit-h> @ InterFace AppDele gate : UL Res ponocler (UF Replication Delegate > @ Property (strong, Non ahomic) Ur Window * window, a Home VieuyControlia * \iowContysller 7 % codein AppDelegate.m :— ee # \mpoah “ApeDelegate hn" 4 \mpoit “ Homeview Con trollot” — void) deattoc i [-WieoContratie sctease’], Csuper deatlo ¢]; 3 did Finish Lasse ching W5ith APP i couton i a nil ¢ bundle 2 nil) > SAE, window. doot ViewConheoller = Self. view Conhto Ulex, 5 #* Code in HomeViuoContiol He lempoak CULKIF/ UEKI? @ interface Home View Con fo lex: UFView Con trolla i J (void) button Clicked % Cicl) sencier ; Cend, K Code in Home View Conhyo {lea z= # impoal * Home Vi eu Centrolley ny” —*—~ " NETView Gntrotia. h” —— * [OSViewConbrolles.h” = "iphone ViewConvollea-h” @end @ implementation HumeVrewCon tra |ler ® Code in view Did Load method! :- — Cvoid) viewoDid Load . : Csupe view Otd Load J; Ceelf view setProme + CaRectMake (o,0,290,460) J, Ut Fomego View * baclg sound T mage = COUT Emoge View aoe Jini kai Mi-— Tmoge: [UEEmege image Nermed : @ “home- png “J Jr Cackg so undimoge Setframe: Self view. pounds J; (Serf. view, adel Subview ; back guound fmoge] ; UI Button * butont= [ UEGuton tus ontwith Type : Ur ButvonTy pe Custom]. Chuttond setrame: Ca RectMasce (loo So, 80,50] ; Chutfond serBack ground io age > (VET mage imageRamecl :@" bettont FeF Ts GosState: UL Gn taolgStafeniosrn ay ; Couttons setfog. 13; Coup. view add SubView » bution J; Cboutont add Target: sf Action e. @ Setectas ChuttonClicleel}: ) fou ContsolEvent ; UL Contso! Tou ch Ue Inside Js US Button x butfon? = ———-» —_—- a above. Coutlond setFrame:CaReet Make C100, 150, Yo.58)J; > as above + ©” butfon?. png"); Coutond set Tag +2); ¢ Csuf vie %dd Sub View : buttondJ, Chuston2 addtouget : self action ' @ gelectos Coton Clicked) foo Control Evens : UT Goatro\TouchVetastde]; UI Button * buttons = [Or Gution button WIHATY pe 7 UT ButtonTy pe Custom ——4 .chove L100,280 , 29,50) 3, = @ “button3 . prg "J, Cbutton3 setteg : 33, Csete. view add Siuo View : butto ng); Clouttong addtorget self action: @ Sotentar CheutfonClicteed : ) foaContro| Evers:£ UE Contro| Teueh¥P LusideT ; 5 — (void) butfonCiicked: Cid) sender j Organ ent bt 2 CULguten A) Sender F Cobtag = =4) I iP bE cumentTi He] ise is Equal ToString :@* J, NWSLog C@ “bukont") : NITViewWContro|lermwnitView= COATT View Controllers alec] init WithN@bNamernil bundle + nil] 5 Eset. view add Sub Views nit Views view]; 5 cue if Cbt, bag 2) ‘astos CE“ button2") ; \ProneViaw controller & nif View =CCip hone View Controller attoc] iniwithNioName + 11 bundle » nity; CsQir. views addgub View + ni HWiew vies) ; 5 ewe TF cot tag = =3) 1 NLog (@" butlon3") ; 1OsviewContsolles x aifView =(ClosvianCon holla, adler} jniteaith - NibNames ml bundle: nil]; Usete. view addSu View : nities. view); yee CC ¥ Code in NITVisocontse {let —Cvpid) ds we Did Load * [Super viewDid Lood 3; Celt. view StF roene : Ca Rect Make (0,0,320, 460); Up Image View ¥ imoge View = [CUTTmage View allot Jini Hi Hh Tm age COT tmage imogeNamed: @Vnirt-eng J]; Cimagevi aw selProme © SUE view. Framed / (ser. view oaddSubVview + imoge View J: Round Reok Ut Buon * bukton = F(UL Button button Wity Type UrQuttonTy pe feeeteer)}; Cloukdon SekPrame, C&Rect Make (49,50, fo, ke) J; (salvia addSubView ; irmegevren bution], Chutton addTorger: serif acon: @ selects ( back Burton Clic iced) SosCorhaolEveatt : UZContuol Event TouchUP Truide I, 5 = (Noid) loaak Bution Click eck ome C sete. viewlsern Ove FromSuper View J, @end # code in \PhoneView Controller -m $- cere eee ew ane OL EL =(void) view Did Load { Code yas gelFrame: CéRectMalee Co,0, 920 460) J; UE TenageView « jmageViow = CC ULTmageVieu alloc) init with Tmage CutTEmage \magenamed; @ “iPhone: png”) J; CimogeViad get Frame * set. diew- Frame) ; (sett. vieg addGubyyaw » tmagevrersy. Ur Gutton apock = CUZButton buttonWitnType + UTGutonRounded Rect] Clack gertrame : CrRectMake( ko, 56,8,46) J: Csertviewd add Subview + bactJ; C back addTarget Sef orton + @ Stlectod C baok Button Clic led) forCoatrolEvents + ULContyol Every TouchUp Tridey- 4 —Cv0id) back Button clicked Cself.view semoveFromSupawiawy ; 3 @ end > code in iOSView controller: 2- eee —(wid) vieDid load ee Set Frome: C@ReckMake Co ,0,390, 460) J; UrEmage view * imageView = [[ UE tmogeViow attec] inikDith eee: LUrsmage tage samed @ " (OS: Png), Cimagevion serframe » get. view. Frame) ; LU suf. vied addSub Vieto, tmoge Via] ; UT Baton -# bank = [UT Buxton owton WithTy pe : UT Butfon Rounded Reoty Cbeate settrame CoRect Make C4290, %9-40 JJ; C5dh view odd SubView sbacle } Cheek oddtasger: sete aclon : @ selector Coack Butoncirctee cf) for Control Eves, UECaMbrol Ever Touch Up TEAuided, j < H(¥oid) bdckQutionciielted CSexF-view aemovefromSuperview J; © end e yore rod —— xox 4 8 BT Ae & Window Apel eer wt ge Taber ert | Frege | a ne} a enenit ee fea] {ea fos jdiseble oe eee => caeate a empty Proyeck with the name window Ar e& fon iPad device D Dsog few images od add some ienoger fo tre project => Create a naw objective C clay fle with the name HomeView Controller * Code in ApPDelegake-h '- HE imposh (Ure / OTT > @ clay HomeViow Contre ler ; @ interface Appdetegate: Ur Responder Ut APP Nealon Oedegrted @& propesdy Cshrong pnonakors cy) UIWndew & WiNdor | i Home Weed Controtig x vireuController > Gerd # Cocke in AopPelegate. mn 3 +A impost * ApeOdeaake ho AE Lem pork © HomeViad ontro We. @ Implementation AppDelegare — (void) deatlog t (- View Controlla soheaey; (super cheattac] s 3 dtd Finish oaraching U0 bh Pree Hecho p Han z SAL window =CCLULWindeo alloc] ima withPrame : [CULScreen maintereen} bound) J atts weleye J SLE. Vi aoControtie: = [C Home View Controle, abloc’] init tuith Nit Name im} bundle: rill SAP. wWindoud Loot ViewControlia = SOA. VED Controller » K Code in UomevignCentrellar.h :- ——— # impost @ interface HomeViedlontroter © OTViewControtler No Asay % imog ey 5 UELable ¥ imageName ; Urgutton * backButton ; UrGutton® NewButbon ; UrEmageNiew % ImageVit ; e Psopesy Cnonatomic, detosa) NS AMY > images j ¥ ————~" UE Lable & tenag eName ; “ ~~ JE Button # bac le Butfon 5 OF Batten # nexb button ; . ne —amnmenn Uigmeg eMCora BR Femogey ad 7 ~ (oid) blinies ~ (vid) puwon cyvicks, Ctol) Sender - @ end * code in HomeVier Contaoller.m t- en re ee @ sya tharize Images, jragename , image View, next button, back Button ; Shoat {ak cunerstnder =o ; bool blinking = No; ~Cid) Ini fOith NibName : Criggtaing «) nibName Od Ni) bundle: CNS Quadte x) nidbBuadless Na i imaga = CCNSAssay aoc] ini twithobjectr. @ “Beach. j pg", @ “Elephans’ jpg" .@ "Stones jeg", @" Tahoe -jpg" @" lion. jg” nd; 5 ORLA SeE 5 3 ~Cvoid) ViaaDid Load Csal-views sebGack gaoundColos : [ULColoa gacy Coles 33; ImageName = [[ULLabel atloc] initWithfeame + CaRect Mak ¢ C259, (00,300 $5) | Cimogename SebText: Limagy obyecity Tedex, cumertIndexl] 7 Cimageniame setTextAlign ment + ScToxt Alignment Center) ; Cimoge name ser Gack4so any Coloa: C UTCOIM ved cetos) J, Crmogename serTentCoiu : (Wxcolor white Coler7): Cimogename s@ Font: (UL fory fo.rbwith Name. @* Coudia" size sF-<)J; Timagensame ser csertnte soction Crabled : N07, Csi, view addsub view » imag eNaney, NsTimet * Hees (NSTime_schectu led Time 1 With Time Irdevat» CNS Timetntevat) Co-25) forget + sae Stlechas + @ sdlectoa Chink) wWerTafo + nil Sepeats, TRUE 7; imageViad = [(Tmage View aoc] iniFwWithT moge + CULTmage image named : Cimages objec Ab Index , Current IndexI} I! CinageViaw et frame: COpectMakeC 100 900,600 goa) ], CimogeView sese TateractonEnobled : PALS EY, Csaeview add Subvier * imag eviews) ; back Buon < [UTButon butlon with Type, 02 Button Ty pe Roun ded Rect]; Chack®ution setframe : C@Rect Make (100, 920,100,S0)}; ChackButon setTities @* Back" fosgtote : UrcontroiStobenlormaty. ChoackButlon setTitletolou: [UE Colas black Colou] fou State: UTContro|StokeNoamaty ; Chatk Butlon seititlecbloa + CUIColos Jedcolos} foashabe ; OiContyo | State Hig Alig hred Chack Button setEroloted = FALE EY ; 7 Chack Buon setAtpha : 0}; C back Button OddTasgel af ackon : @ selector Coutton Clicks) Ga ConteolEverts, UTContral Event Touch Up Fnatdey; CSQIE. View addgubWiews back Buttony; HetGwton = COT Button QutlonwitnTy pe + OZ Button Ty peRoun dled Reg ; © [ee Qutton setPrame: CORect Make C6008 20, 100, 80) J Ji Creat Qution sektiHe: @ "Ney" Rustate. UTcontsel Stabe Neamag J. CnextGutlon setTi tlecolos* [ULC los black cola PosStare » UT trol Stake osmary » CoextQution sefTitieColas ; CorColay sed Colos J FosState UTControl Stabehigh lighted J; Creat Button SebEnobled: TRUE]; Ny [reatQutlan seAleho: oJ; Chexgaudon Add Tage. Seip ackon: @ selects Chustenclicts fos Contwol Evert: UE Contye [Every Touch Up Trutde)) » Csett. amiew add Subview : nextBudony; y ~(Cvoid) button Click = Cid}sender i UlBullon* bt = CUTQutton aS sender; TF CECE current Title) 1s Equa To Stai ng + @* Neck") 1 $+ ChuneutTadex ; Ciemageview sertmage: [UrImage imageNamed » Cimagey ObjecWMhindex’. cuneryTndex}] J; Cimoge Name cettert:, Cleage objectAt Index: cussentnder] J. SEE CE easton CE CBD back button is Enabled) == FALSE) L back Button set Enabled : TRUEY ; IF Crumeny Index = = Cimeges count] -1) (next Guten sercnobled : FALSE); 4 else TP CE bt Cunera Tite) is Equal to Siaing : @ “Baee] ) { ~~ cunertTndex; Cimage View cor Tmoge > [UZTmage ImogeNamed + images Object AFENd er: cus eretodery JJ; Cimageniame ger Text : Cimages objerat Inder : cusreny Lacte JJ 5 \FC [nextgution ig Enabled z= FALSE) CrextQuton kerEnadlede e: BTRLET. iF (cuuerdTnder = = 0) Chock Button SttEnabled: FALSE, 3 3 ~ (void) blink if ¢ blinking = nlo) t (Hienagename cdpha =o j N CtmageVieus SerAlphar: oJ; Cimage Name SBackgao und color + [UIColor whiteColasd J; Cimag Name SetTextColor: CUTCalos agdeoivad 4; blinking = YES; 5 Use 1 tmagentae. alpha 2 ; Wimage View sept pho); & Cimage Name gerGacicground Colas; [Uz Cola Bebe coleaJd; C Limagename sekTextColoa: [Ur Colos Geol), blinticg = No; ~ 3 —Cvoid) deptoc Crmoges seleose) ; Ctmogename schease’s j ( imogevied achease] ; C next gutton selease I; Clack gumon ackeases; Csuper deatloc ]; end 5 ——*o Xx og f1o|0'3 #¥ Caeabe oO single vietwo 10S appl’ with the name WindawAppS => open viewContsoller-zib & place Following objeaks - > Label object dog fo nie file & change the ou Si buter + Make the alignment os center & fort size as do. —> Psog the Round Rect button otjet to the silo Mile * Sek the fag ax 4 & make type a2 Custom & remove bution He. * Daag a image fo the pioject with the name left. png & make the size ar 93x20 dimension. * Sect fhe bution object & change the image cu lett eng —_ Daag another Sound Rect: butiod & change the atta butler type 4 Ceutforn * tog ws 2 * and Gelect the image aught png 7 Daag sight. png to the pavject then only it is visible —> Place the imageView object on nib file. and change alignment properly — Go to View Csntroller-h - * Code in View Contaoler-h i> # impoat CUTKIE/ULKIth> @ interfoce Vicon roller ~ UEViewCentre (ler Nis Mutable Ayray se imagelist > NsTimer * timest NSTimer * Hmex 2s é& Property Cnonakomic Re tain) NsMutable®aray # imagelish ; —— NSTimer Hert , %* timer? ; ——— TBOutleh UlLabed * label ; FGOutlet Urputton® back ; ——~ TBOuHet UTButton x next » £6 Outlet OLTmageviend * imageview; ” —CTBAcHon) button@licle + Ciel) senclee. — (oid) blink ; — Cvoid) hidelbutlory ; @ end —? Open ViawWcentsollersrib & make He welalion ber? FBOuHer objeck & UTObJects- * sag Prom Files owenet to label 2 select lobet ourlor. C we need to pre sight mowe button until making the adation) ~ oo Prog Riles owner to bution & Select pack outlet. ~ Daag Ales owner to another button object & Select ‘next’ ourlel * Daog fiom Files owner to imageView & select imogviao object % Actions s- —> To make the actions for the button we need to chors? following Procectunes. * Daag buttonVI fo Fiast Rerponder & Select buttenclicle meths * Same Procedure for second bution also. & Code in View Controller 3- cee Otol oO @ syn thasire label back, next, imagelish -imageniea, Hmett Homer ; Shear int cindex: bool isQlink = No; boot isHide =No; —Cvoid) VieoDid load ‘ 4 [super view Did Load J / [settview set GackgsoundColod : [UECOIod blackcolor} °) Imoge\st = [CrsmwtabieAsrayg wit]: fox Cint ied isto; THE) anor Lim agellsh addowject > Crissising staing\Withfoa mar ; Gimager f-jeg" iI )s Clove gergockgaound Cotes : [Uz Cola cohitetolos) ; Clabe set Text dolar: [UEColoa sed cola) J: Clobel settext: Cimage list object AtIndex + Cinder}} ; Honerd= Cristimes ‘schecteles Timer With TimeTrterval ; (NSTieneEn tena!) (0.95) lagel: Saf elector : @ selee far Chlink) WetTAb ; nix depeals + TRUE J; F waste enw code —(£GAcK on) butlonClick> Cid) cerder UTGutlon * br = CUZ Quon *) Senda ; TF Cob. tog == t) q --Cindlex ; Cimageview setTmoge: [05 Fmage imagenamed : C image list Object At inde + Cincler}]] ; Chaba ser Texas [image list ob)yect Hinder ; Cinder} 4}; laber-seried—_Cmagehist—onjecbAttndereraderyy, TF CEneat igtrabted) == FALSE) Crext setEnabled = VES}; Crent setAipna tJ ; 7 if CCindex= =0) Check setFnabled : FALSE] Chack serena: 04; 5 § wwe t arcinder; TimageNiew sebtmage: (Uitmage imageNlamed : Crmagelist objectAt Inder + Cindy} }, Liabal setTew: pimagiist olpjectAbEndex + ciadexJI; TE CCback isffablel= = pALSE) Chack serEnablgy : TRVES; Chace setPlehasiy; § TF Cotnderse Cimagelist cours J -\) * eeu stu Enabled. FALSE); Creat setAjeha: 01, 5 5 5 ~ (void) blink TF is Blink = = No) Clabes sekGackgsoundcolas: CUTCola aed colar} J. (labe sertertCo tes - CUECIR wed whitecdios) }- isBltrk ES a> ele © Glabel sertackgsoundérios + (U7ol0s whileColar} J, Clawel Setfextcojor :fOrColot sed Clon}; teBlink = NO —Cveid) hideloutlony 4 iE CisHide= = No) Coact selAlpha: od- Cnext setMpha:o3, isHide=Yes; CHimet2 invalidate]; //'stop'Hme. lout doeinit kiN the ob}éel ‘i 5 | Ovid) touche Begin: (NSseba) touche withevery + CUr Eventajevert $ NGTimer # Hme=CNGTimeL scheculed Timer With TimeTrteLas ; CNSTi meTnterval) (3) Taser: cele S#e’chor v © selectos Chidebutdom) serving: il srepeaks TRIET- Mme? = ime; is Hide = nto; JF CCback IsEnabled) ) Chack suAlpha:!}; if Clnect istnabledd ) Cnext set Alpha: 17; 5 ~ (Wold) deattce Cimageligt dee acteare J; Climend seteared; CHmerd seleaseys Csupper deawoc); 5 29/10/2013 # Create O single view ins appl” with the name Login Hep * Open Viewocontroller.db & Place following controllers \) Lobel i Text > used. Sire 16 Text Alignment —> \eft ; 2) label !- Teet > Paurooad Teat Aignmentt — lef}, 6i2e 315 3) UE TextField s- placeholder —> Useaname A) UE TextPield :- Placeholder > Patswoad , secure enable 7] 5) Uleuttoa &- TiHe — login 6) Ackvily Indicates View ¥* Code io VieoCootaoller-h t- H impoat Cure / Ur Kit-n> @ interface ViewContro ler: UZ Viet Controlien CULTatfield Delegate? t f e Property Cnonato mic, AetoJN) TROule UzLabel * werlabel ; —- — UF Label Pswod Label OT TextField # ULeL 7 Ul TextField * pswol UG ution # login | UERetvity Endicotos View loadking ; — (ToaAcHon) login Button Chicled: Cid’) Senda @end + Moke the selgtion ber? Toutes & Files owner Files Owner, t—> lobeh -—> userlabel L lobe — pswd Label L>UEfextPield —> wer +> ULtenr Field —> Pswd r—> Button —> login Actividy Tra cates —9 loading * Make the buttoaActon to login button & select login Guton- Clicleed - Button —3 FisstReipordles — login Gut onehvcteest * Code in viewContso ler. m z- @ synthosize userlabsl , pswa label ; tt wer, Pswds Login, loacking : # progma -mark UFTextFiaddelegatomethad ~CBOOL) textCieicl Showd Rekuin + (UTTeXt Field #) texhFicld { Ctoxk Field sexign Fiait Ret ponder); deruin YES; 3 ~ (G00L) fextFietidsShould @ ; Sg Ecuhing = (UT Text Fiala ¥) ‘tex fiebl TF Chen pied tag== 4) (User Label SetTearColod : [UEColod Tolacle Co{ts JJ! ete IF Cteetfidd. tag = 29) CPswdlabel settexr Colas > (ULC los black Gla]; Crext Field SerReruntenTyre OrRemuinkey Done] + AeUAN YES; He pragma —mawlt ViwdControjiex Methody = (Noid) view Did Load i Csuper Vie Did Load J; Cuer ser Delegate + sete; Cuset setTag : 4) ; Ceswd sekFeag 95> surDelegate: self]; CAswd sertag «9; 5 ~ (TB Ackon) login Bution Cicked { Nestaing # UNames @ "Bolu; Ud) senda. NSSHng # Phame =< @" 1234" UTMlet View * aberkonil ; Cloooting stags Ani mating J; { atest = [TU AleUViad alloc] ini}WithTiHes @ “Cegtn Alek” if CCuser terry is CquasToStang @°" J) menege + @™ User ic Empty" delegate » mul ConcelBation tille :@"Ok" otheButontities 2 ul, vly, Codert chow); Curertaba cd Terd color ; (ultolor aed oreryd; Cloeding chpAni mali ng J; 5 ate TF (LC Psd tent] re Equorfostaia + @" "I ) ake = ( CUTA leat View otiocJini Hu thBdHe: ©“ Login Alert menege: @Passiad ts Empty” clelegate + nil Cancd Guttonsitle » @°OW" OthaurtontHtie: nil, MI; Coterr show's ; Cesvod Label serTetColor, CUbColor sed Cols » Tleacking StopAnimoting’S : 5 eye if (fuser text] Care Trreniative Compales, uname] ) 1 adert {[UTMeUView Alloct] initwithTiHe 2 @ " Lagin Blert" memeye: BY invotiol wie" delegate : nil cancelQutton Fi He mt SO" otha guttonbHes wl nil], Cale show) , Curertaba sertenttola: (ULCla redColo J); Tusa seed. © "J; Coading stoparimating );, 5 auc ih £ Pswd tej ‘5 Equal To Staing 1 Pname = = FALSE f oleuk = [ [Ur MentVi ew aoc Jinit wth KHe: @ “Legion Alea” mem ge 1 @* Invalid Parsusord “ clelegate + ail Cancel ButtonT He > @™ ot" (ater chow J; otmerButten Titled : nit, mul J + r ~ CE Pswd label gekTentColna: CUTColos red Coloa) J, fi 7 Cpsuxk ser teat: G4; (loading stopPaimosing 3; oe I] Sleep (3); Cuser ser Alpha :oJ! (pswd seralpha: 0] : ( urerlabed Serpipha :07 : [Psexllabel set Pipina 0): L Nwacting set Pipa: 0); C login sesAlena:o) i Utlobe a label = [[UiLebet AUC] inifwith Frame : (a Rect Mace C20, $0, l00, Gu) JF Llobe serteu : @ “Welcome”; {eel view. add Sub View + label J ; 5 [alercd aele ose; 5 @ end So Hol s013 + By using Trig contsoller we con pax olerrvieros fn device - When we are working with olerbView » iF cannor ‘& Customized. it, default view onty visi ble: + Tf we aequised fo handle UrAletvie button artions then we aequised to implemers UrflerrviewDelegate methedy ‘ Generatty these. al methods ore opHonal ie if we sequiaed yo perform fre faak Fhen onby ecomm onded to go fox. delegate methods UTSWikeh 3 Bg using this contro} we can place switeh’ * UTSwiteh hawi ng hoo OPH 1-2 OM oA OFF + When we ate cooaking with Urdwiteh eontiol Men we need fo handle UltontrolEventValueChanged OtHon. Cnosmatty for buttons UZ Control Evens Touche Enutee). UTStepper oe . By wing this Controller we can implement cliop down Vist behaviour in 10S Generatly thig eontrotler ig Xecommonded te ute wohe 9 We seguised fo place Come quantity value: Cs OtStepper having Hee majoa Propenttes ie. minimum Value, maximum. value & Step value. + Minimum Value wil provide minimum stepper cata, martimum Natue cori! PAovide Masimum Steppes data & Step volue provide diffrence ber? Pueviow volute & 7 few value. + When we are voorki ng Urstepper if we required fo access skepper custerk volue thea go fas. value Propesty + On ULSrepper we sequised to handle Uzcontro|Event- Nammethanged actor UISlideri- : 8 using Enis contooller we can male volume contro! vieo » When we are woking with UTslider then we need fo set MAIMIUM, MOdMUM value + When we are wosking with Urslider, we sequised fo handle USControl Evert ValueChange Action # Cogabe a singleview appl” with the name Window Apps * Code in View controller. h é- eae in Vien Contreras 4F impos Curkit /UEKIT ND. @ interface ViedControer + UZ ViadContrelle, CUZ Pleat View Del ef ates OT Ales View & Hest ; UI ubton& bukton 7 UE Gui ten SwitehNiew ; ULStepper» Step perView 7 UsLobel * label: ~ (void) button licked 5 ~Cvoid) Switch clicked 5 —(Woid) shepperClicked 5 =(Woid) sliderclicked : CUrStider % ) Slides; Wfoa local objects need to pau arguments @ end * code View Controtier ~Cvgid) vied Did load ¢ Couper View Did ood}; baston= [UL Budton buttonuithTy pe + CUzG uttonRouncectReef) J; Clutton setframe + ECG Rect Make (20,59, 150, €o)}; Cloutton add Tag ek: elt acton: @ Selecta C button Clicle @) fox Control Every» UlLConrolEvent Touch Up Frsiole Jy Chutton serTitle ; @ “click” PouStabe ULControvstatentor mal | ; Tsar vian odd Subview 2 button]; swikh View = CCUTSWikth alloc] inikwithFrameé : Cohect Make (30,160, 50,5003; Cswiteh View getEmabled t YES; Cewiteh Vie — setOn > YES), Cawikivend add Youget : cele aechon: @ Selecta Cswsiteh Cl ccbed) for Control Even: UT COU o] Evens Valuechanger J; Cate Nie addsubview® , suiteh View’); & Stepper Views [COIS beppet OMec] initusi th Frome > CaRect Nake (30,200, 100, So); [Steppaview getMinimumValue + oJ; (skepperVied setMaximum Value . 1°); L Steppe View sebvedue sefthe Value + 2]; Cstepperview adld Tou get . Sele action :@ Selecta Csleppert Iectat) Sa Controieve rk + Ullontro! EventVatue Chon ged J; Csetf-view odd Sub view . StepperView] Lebel = [CU1Iobel oLtod) inintwith Frame + CORectMake (180.19 0,200 ,60)}; Caf. view addSubvi ve + label, (lobe gertedk @° "J; UrSlider * Sliders (C Usslider able] init with Frame: CaMectMakel3o 200, 100, $0) J; COPE Fine Tronifoam roma = Ca BFF eT ront form Malee Re raion CM_PE # 08); glider» traruform= trond j (slide sed MinimumvVolue +0] ; Cslider set MordmumVawie | oo); (slider addTaiget : see action: @ selector (slider Clickedt's ) Ga Controlévenk + UlControlvent Value Change ty - Tseif-view addSubviewd + Side]; —Cvoid) S\rdorClicked > CULSlidet*) stider NSlog C@" Zt") Cink) Cstider vaLue}); Clabes set Text: CNisghaing Staieg With Foamas ; @'slet Value: Cit) Leider vawe JJ]; 3 ~(Woid) steppesrClicked NSlog CO" 71", Cint) (stepper View vaLuey ); Clobe setterxt + Criss hing Stabeguoith Foamar + ©" steppes volute: Zi", Clat) ([otepperview value} J, 5 = (void) SWikeh CW eed, Nsteg (@ * (Aide Funch’on "); TE C[swilenVien isOnj= = FALSE) i Clutlon setHidden* Yes}; Csdf.Viud setGockgsoundColos + [UT Colos RedCote}J; 5 a Cwen setHidden: Noy; (self. view set Gackgaouind Color. [ULColos WhikeColad J); 5 5 — (oid) buttoncitekeck £ crest > CL ULMet View attec) INitWiMTIHes @ "Alert View" mettege s @ “Sect OpHon" delegate: self Cancel BUM on THE * @ “ance” other QutiodTiHees: @ "ok", e onl nue” nil > . Caet show); ccs -Cvoid) abertView ; CULAletView 4) alert View clic ked Button Al - Trdex (NSTrteger) button Index tt CburtonTndex = =0) 4 NSlog (@* iF is cancel button" ), Coubon sek TiHe: @™ conea fou stater UzControts hobe Normal], § else (€ CbuttonIndex == 4) NSlog CO™ iF is O1¢ batton") ; Cbeuton settle: @° OK" fa Stat ets: Ur ControiStake Normal J’ 5 eRe Charis lodge 2/25 Nslog C@* it 43 Continue betton”) 5 Cbution setine : @" continue’ foastate® Urcontrolshake- Normal }j j 4 ~ (void) deatloc Latest sdhoage] ; Chation setease J; CewitehView seleased; (Stepper View select); WI Csiider View seleared; Clove) aeteaye’l; Csuppe deatoc]; 5 @ end. 02/41) 2013 * Ul TextField :- , Gy using His view we ean place Single Vine feat content . 7 + Men we are working UrTextField we eqiiae to implem-~ ent UtTextField Delegate methoots * When we are edi keg UtTextField date then automah cally Keyboard toill Appear: * Generally OLText Field having Following Paoperhes. 4) GosderStyle S) Rekunkey Type 2) AuboCosrection Type 6) Delegate 3) Key boaad Tyre %) Enobled 4) Key board Appearance 8) Secure /SecurityTextfentay. + textfield Should Rekutn methecl votll cat! when coe Click 04 Aun button of keyboard. tent Field should Geg intatitiog method will call when editing is shorted. : fend Piel shoud £ nd Eebiting Is canted when edits ts Pinto hed * To height the keyboard on any fetfiel tren we need fo con Ataign Pisat Responder. method. * When we sequise to focus on any one of the text Field then agcommended logo tw become FisstRerpondler. methoal. s Lohen we sequised fo curate non editable text fietol we doe nt per any properties go, we aequised to Aide Wye keyboard when user fouches the Speci fre FextGied Cin we cage we can disable weridierachion allo) © Uv Text View _O Text View ¥ * When we Lequised fo enter multiline content then acco- mmonded fo ‘use UTTexctVieo. * OflextView doen't having bosderstyle property. So we Aequise to make cusbemhed boudet- + When we me cwagting coiHn UtTextView then we sequise fo handle U EText view Dele gate method - * When we are Woking with UT ertView fren sehuin button doesn: F having defautt acton. So Programa cally toe aequised fo hondle -tekun button action % Cilate O single view application with name window ppt + impost QuattezCoue FramewWoadle bo cartent pucjeth (Goto Build phase 9 Line Binoay With Libsarres +) * Code in ViaoContsollet+h7- ———, eee # impoat CUTKHE/ OLE F-hD Cinlaface viewCentuoller : UrvewCenhieller ( ULTad iad Ddegare7 < OF enviadDalegate> UFTextFidd x one, UtTexk Feld x oo: UTTent Field # Huee > UptertView « tek ; C&Reck ViewSizes 5 @ proPerty C nonakomic ,reterin) Op Tewthield # ones e K to 0; Cena

You might also like