0% found this document useful (0 votes)
10 views

Exception Handling

Exceptional handling in anroid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Exception Handling

Exceptional handling in anroid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Qa Excpthion Handlinga

dn excapthon is a special condihon that intemupts


the normmal owfiow ofof program
program excution
Thereare vanithy of reasons why n
erception.
may be generatel

Exaphont can bebe qenerated


geneatedl bu
by harawae
harolwan a wl au
sofrware
EAception handling is madle available in Objechve-c
with foundation cas NSException.

Objechve -C supports our compiler direcives


excapion handling
Thi's block tniet to
try exeeute a set
of Statements

(catch This block tie to catch the


cephion in the try blo ck

(throw throw excaption if you frd yourself


in a situation that indicated
programming eor, and you
you wat
o stop the application tom running
finally This block contain set of statemnts
that alwos execute.

Ex aumple of situation that an


generate emor
include ’

division by
undanflow
overfow
calling undefnad instruchion.

Exomple pragram for xephon hardling

# import < Foundlathion Founclation. h)


int main )

NSAutoreleasea Pool *pool= [[NSAutorelease Pool


allsc ] init];

NSTlutableAray * aay - [[NSMutable Array


alloc7 init ];
NSSting *string == Caray objectAtIndlux lo],

@catch (NS Ex caption *excup tion).


NSLog C "%Q excephion. name);
NSLag (@Realon: % excepion. reason ),

Qfinally
NSLog (@ " fnally always Executes "):

Cpool orain]
retum 0;

You might also like