Block declared variable visible outside?

Posted by fuzzygoat on Stack Overflow See other posts from Stack Overflow or by fuzzygoat
Published on 2010-04-01T12:43:30Z Indexed on 2010/04/01 13:03 UTC
Read the original article Hit count: 354

Filed under:
|
|

If I declare a variable within a block (see below) is there a way to specify that its visible outside the block if need be?

if(turbine_RPM > 0) {
    int intResult = [sensorNumber:1];
    NSNumber *result = [NSNumber numberWithInt:intResult];
}
return result;

or is the way just to declare outside the block scope?

NSNumber *result;
if(turbine_RPM > 0) {
    int intResult = [sensorNumber:1];
    result = [NSNumber numberWithInt:intResult];
}
return result;

many thanks

gary

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa-touch