Académique Documents
Professionnel Documents
Culture Documents
AppStatesandMultitasking
Q8.WhyanapponiOSdevicebehavesdifferentlywhenrunninginforegroundthanin
background?
A.Anapplicationbehavesdifferentlywhenrunninginforegroundthaninbackgroundbecauseofthe
limitationofresourcesoniOSdevices.
Q9.Howcananoperatingsystemimprovebatterylifewhilerunninganapp?
A.Anappisnotifiedwhenevertheoperatingsystemmovestheappsbetweenforegroundand
background.Theoperatingsystemimprovesbatterylifewhileitboundswhatyourappcandointhe
background.Thisalsoimprovestheuserexperiencewithforegroundapp.
Q10.Whichframeworkdeliverseventtocustomobjectwhenappisinforeground?
A.TheUIKitinfrastructuretakescareofdeliveringeventstocustomobjects.Asanappdeveloper,you
havetooverridemethodsintheappropriateobjectstoprocessthoseevents.
AppStates
Q11.Whenanappissaidtobeinnotrunningstate?
A.Anappissaidtobein'notrunning'statewhen:
itisnotlaunched.
itgetsterminatedbythesystemduringrunning.
Q12.Assumethatyourappisrunningintheforegroundbutiscurrentlynotreceivingevents.In
whichsateitwouldbein?
A.AnappwillbeinInActivestateifitisrunningintheforegroundbutiscurrentlynotreceiving
events.AnappstaysinInActivestateonlybrieflyasittransitionstoadifferentstate.
Q13.GiveexamplescenarioswhenanapplicationgoesintoInActivestate?
A.AnappcangetintoInActivestatewhentheuserlocksthescreenorthesystempromptstheuserto
respondtosomeevente.g.SMSmessage,incomingcalletc.
Q14.Whenanappissaidtobeinactivestate?
A.Anappissaidtobeinactivestatewhenitisrunninginforegroundandisreceivingevents.
Q15.Nametheappsatewhichitreachesbrieflyonitswaytobeingsuspended.
A.Anappentersbackgroundstatebrieflyonitswaytobeingsuspended.
Q16.Assumethatanappisnotinforegroundbutisstillexecutingcode.Inwhichstatewillitbe
in?
A.Backgroundstate.
Q17.Anappisloadedintomemorybutisnotexecutinganycode.Inwhichstatewillitbein?
A.Anappissaidtobeinsuspendedstatewhenitisstillinmemorybutisnotexecutinganycode.
Q18.Assumethatsystemisrunninglowonmemory.Whatcansystemdoforsuspendedapps?
A.Incasesystemisrunninglowonmemory,thesystemmaypurgesuspendedappswithoutnotice.
Q19.Howcanyourespondtostatetransitionsonyourapp?
A.Onstatetransitionscanberespondedtostatechangesinanappropriatewayby
callingcorrespondingmethodsonapp'sdelegateobject.
Forexample:
applicationDidBecomeActivemethodcanbeusedtopreparetorunastheforegroundapp.
applicationDidEnterBackgroundmethodcanbeusedtoexecutesomecodewhenappisrunninginthe
backgroundandmaybesuspendedatanytime.
applicationWillEnterForegroundmethodcanbeusedtoexecutesomecodewhenyourappismoving
outofthebackground
applicationWillTerminatemethodiscalledwhenyourappisbeingterminated.
Q20.Listdownapp'sstatetransitionswhenitgetslaunched.
A.Beforethelaunchofanapp,itissaidtobeinnotrunningstate.
Whenanappislaunched,itmovestotheactiveorbackgroundstate,aftertransitioningbrieflythrough
theinactivestate.
Q21.Whocallsthemainfunctionofyouappduringtheapplaunchcycle?
A.Duringapplaunching,thesystemcreatesamainthreadfortheappandcallstheappsmainfunction
onthatmainthread.TheXcodeproject'sdefaultmainfunctionhandsovercontroltotheUIKit
framework,whichtakescareofinitializingtheappbeforeitisrun.
CoreAppObjects
Q22.WhatistheuseofcontrollerobjectUIApplication?
A.ControllerobjectUIApplicationisusedwithoutsubclassingtomanagetheapplicationeventloop.
Itcoordinatesotherhighlevelappbehaviors.
Itworksalongwiththeappdelegateobjectwhichcontainsapplevellogic.
Q23.WhichobjectiscreatebyUIApplicationMainfunctionatapplaunchtime?
A.TheappdelegateobjectiscreatedbyUIApplicationMainfunctionatapplaunchtime.Theapp
delegateobject'smainjobistohandlestatetransitionswithintheapp.
Q24.HowistheappdelegateisdeclaredbyXcodeprojecttemplates?
A.AppdelegateisdeclaredasasubclassofUIResponderbyXcodeprojecttemplates.
Q25.WhathappensifIApplicationobjectdoesnothandleanevent?
A.Insuchcasetheeventwillbedispatchedtoyourappdelegateforprocessing.
Q26.Whichappspecificobjectsstoretheapp'scontent?
A.Datamodelobjectsareappspecificobjectsandstoreappscontent.Appscanalsousedocument
objectstomanagesomeoralloftheirdatamodelobjects.
Q27.Aredocumentobjectsrequiredforanapplication?Whatdoestheyoffer?
A.Documentobjectsarenotrequiredbutareveryusefulingroupingdatathatbelongsinasinglefile
orfilepackage.
Q28.Whichobjectmanagethepresentationofapp'scontentonthescreen?
A.Viewcontrollerobjectstakescareofthepresentationofapp'scontentonthescreen.Aview
controllerisusedtomanageasingleviewalongwiththecollectionofsubviews.Itmakesitsviews
visiblebyinstallingthemintheappswindow.
Q29.Whichisthesuperclassofallviewcontrollerobjects?
A.UIViewControllerclass.Thefunctionalityforloadingviews,presentingthem,rotatingthemin
responsetodevicerotations,andseveralotherstandardsystembehaviorsareprovidedby
UIViewControllerclass.
Q30.WhatisthepurposeofUIWindowobject?
A.ThepresentationofoneormoreviewsonascreeniscoordinatedbyUIWindowobject.
Q31.Howdoyouchangethecontentofyourappinordertochangetheviewsdisplayedinthe
correspondingwindow?
A.Tochangethecontentofyourapp,youuseaviewcontrollertochangetheviewsdisplayedinthe
correspondingwindow.Remember,windowitselfisneverreplaced.
Q32.Defineviewobject.
A.Viewsalongwithcontrolsareusedtoprovidevisualrepresentationoftheappcontent.Viewisan
objectthatdrawscontentinadesignatedrectangularareaanditrespondstoeventswithinthatarea.
Q33.Youwishtodefineyourcustomview.Whichclasswillbesubclassed?
A.CustomviewscanbedefinedbysubclassingUIView.
Q34.Apartfromincorporatingviewsandcontrols,whatelseanappcanincorporate?
A.Apartfromincorporatingviewsandcontrols,anappcanalsoincorporateCoreAnimationlayers
intoitsviewandcontrolhierarchies.
Q35.Whatarelayerobjectsandwhatdotheyrepresent?
A.Layerobjectsaredataobjectswhichrepresentvisualcontent.Layerobjectsareusedbyviewsto
rendertheircontent.Customlayerobjectscanalsobeaddedtotheinterfacetoimplementcomplex
animationsandothertypesofsophisticatedvisualeffects.
BEGINNER
Q: Whats a struct?
A: A struct is a special C data type that encapsulates other
pieces of data into a single cohesive unit. Like an object, but
built into C.
Q: Is a delegate retained?
A: No, the delegate is never retained! Ever!
INTERMEDIATE
ADVANCED