if(eventRecord.byName){
presented.text = eventRecord.byName;
float descPos = 50.0;
}else{
[presented removeFromSuperview];
float descPos = 35.0;
}
CGRect descFrame = CGRectMake(125, descPos, 185, descStringSize.height);
I’m not even sure what to do here since the whole time I’ve been working with objective-c has been with objects. But now, I need to set a variable with a float value depending on the condition. I’m not sure what the syntax should be.
On a side note, xcode4 has the last line as an error because descPos is undeclared. But won’t it be once the condition is run?
You are only declairing
descPoswithin the scope of theifstatement. To access the value you are setting inside theifblock, declare it beforehand:Otherwise, the way you are doing it, the value of
descPosis discarded as soon as the block ends (with the}brace).