编程新手。使用随机数生成器和每个类别的问题的案例陈述创建了具有不同类别的测验应用程序。我有2个问题。 一个是.m文件中的一行。每个类别以 - (IBAction)xyz:(id)发送者开头;在一行中,我不断收到错误消息“expected expression”。我还注意到,这条线表示侧面指示按钮链接的圆圈没有出现。我尝试重新链接按钮,但我收到相同的错误消息。
(不确定第一个问题是否导致第二个问题)第二个问题是在.m文件的同一类别中我一直收到这些错误消息:Break或case语句不在循环或switch.I有复制和粘贴代码使确保缩进和拼写正确来自没有此错误语句的类别,但我仍然在代码的这一部分中收到这些错误消息。我不知道如何解决它。请帮忙。我包含了上述错误的行。 THX
`
}
-(IBAction)OphthalmicInstruments:(id)sender{
Cat1.hidden = YES;
Cat2.hidden = YES;
BasicOptics.hidden = YES;
EyeAnatomy.hidden = YES;
OphthalmicInstruments.hidden = YES;
Lenses.hidden = YES;
Transposition.hidden = YES;
Standards.hidden = YES;
Frames.hidden = YES;
Random.hidden = YES;
Question.hidden = NO;
Answer1.hidden = NO;
Answer2.hidden = NO;
Answer3.hidden = NO;
Answer4.hidden = NO;
Right1.hidden = YES;
Right2.hidden = YES;
Right3.hidden = YES;
Right4.hidden = YES;
Wrong1.hidden = YES;
Wrong2.hidden = YES;
Wrong3.hidden = YES;
Wrong4.hidden = YES;
SelectCategory.hidden = YES;
int OphthalmicInstrumentsQuestion = rand() % 33;
switch (OphthalmicInstrumentsQuestion) {
case 0:
Question.text = [NSString stringWithFormat:@"The PD ruler is used to measure:"];
Right1.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Intepupillary distance"];
Answer2.text = [NSString stringWithFormat:@"Vertex distance"];
Answer3.text = [NSString stringWithFormat:@"Intraocular pressure"];
Answer4.text = [NSString stringWithFormat:@"Basecurve"];
break;
case 1:
Question.text = [NSString stringWithFormat:@"A distometer measures:"];
Right2.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Interpupillary distance"];
Answer2.text = [NSString stringWithFormat:@"Vertex distance"];
Answer3.text = [NSString stringWithFormat:@"Intraocular pressure"];
Answer4.text = [NSString stringWithFormat:@"Basecurve"];
break;
case 2:
Question.text = [NSString stringWithFormat:@"A tonometer measures:"];
Right3.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Interpupillary distance"];
Answer2.text = [NSString stringWithFormat:@"Vertex distance"];
Answer3.text = [NSString stringWithFormat:@"Intraocular pressure"];
Answer4.text = [NSString stringWithFormat:@"Basecurve"];
break;
case 3:
Question.text = [NSString stringWithFormat:@"A lens clock measures:"];
Right4.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Interpupillary distance"];
Answer2.text = [NSString stringWithFormat:@"Vertex distance"];
Answer3.text = [NSString stringWithFormat:@"Intraocular pressure"];
Answer4.text = [NSString stringWithFormat:@"Basecurve"];
break;
case 4:
Question.text = [NSString stringWithFormat:@"A pupillometer uses a light to get a reflection from the :"];
Right1.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Cornea"];
Answer2.text = [NSString stringWithFormat:@"Retina"];
Answer3.text = [NSString stringWithFormat:@"Iris"];
Answer4.text = [NSString stringWithFormat:@"Sclera"];
break;
case 5:
Question.text = [NSString stringWithFormat:@"In this system a hypothetical box surrounds each lens, and it is used for standard measurements of lenses and frames:"];
Right2.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"MRP"];
Answer2.text = [NSString stringWithFormat:@"Boxing"];
Answer3.text = [NSString stringWithFormat:@"Dato"];
Answer4.text = [NSString stringWithFormat:@"Monel"];
break;
case 6:
Question.text = [NSString stringWithFormat:@"A,B,C,DBL,ED,PC, & DBL are all part of what standard measuring system?"];
Right3.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"MRP"];
Answer2.text = [NSString stringWithFormat:@"Datum"];
Answer3.text = [NSString stringWithFormat:@"Boxing"];
Answer4.text = [NSString stringWithFormat:@"Monel"];
break;
case 7:
Question.text = [NSString stringWithFormat:@"In the Boxing Measurement system for lenses and frames the A represents:"];
Right4.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Distance Between Lenses"];
Answer2.text = [NSString stringWithFormat:@"Minimum Blank Size"];
Answer3.text = [NSString stringWithFormat:@"Vertical Measurement from outer to inner lens edge"];
Answer4.text = [NSString stringWithFormat:@"Horizontal Measurement from outer to inner lens edge"];
break;
case 8:
Question.text = [NSString stringWithFormat:@"In the Boxing Measurement system for lenses and frames the DBL represents:"];
Right1.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Distance Between Lenses"];
Answer2.text = [NSString stringWithFormat:@"Minimum Blank Size"];
Answer3.text = [NSString stringWithFormat:@"Vertical Measurement from outer to inner lens edge"];
Answer4.text = [NSString stringWithFormat:@"Horizontal Measurement from outer to inner lens edge"];
break;
case 9:
Question.text = [NSString stringWithFormat:@"In the Boxing Measurement system for lenses and frames the ED represents:"];
Right2.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Distance Between Lenses"];
Answer2.text = [NSString stringWithFormat:@"Minimum Blank Size"];
Answer3.text = [NSString stringWithFormat:@"Vertical Measurement from outer to inner lens edge"];
Answer4.text = [NSString stringWithFormat:@"Horizontal Measurement from outer to inner lens edge"];
break;
case 10:
Question.text = [NSString stringWithFormat:@"In the Boxing Measurement system for lenses and frames the B represents:"];
Right3.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Distance Between Lenses"];
Answer2.text = [NSString stringWithFormat:@"Minimum Blank Size"];
Answer3.text = [NSString stringWithFormat:@"Vertical Measurement from outer to inner lens edge"];
Answer4.text = [NSString stringWithFormat:@"Horizontal Measurement from outer to inner lens edge"];
break;
case 11:
Question.text = [NSString stringWithFormat:@"The geometric center line in the Boxing Measurement system is:"];
Right4.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Distance Between Lenses"];
Answer2.text = [NSString stringWithFormat:@"A Measurement"];
Answer3.text = [NSString stringWithFormat:@"B Measurement"];
Answer4.text = [NSString stringWithFormat:@"C Measurement"];
break;
case 12:
Question.text = [NSString stringWithFormat:@"In the Boxing System for lenses and frames the C represents:"];
Right1.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Distance of lens through geometric center"];
Answer2.text = [NSString stringWithFormat:@"Minimum blank size"];
Answer3.text = [NSString stringWithFormat:@"Vertical measurement from outer to inner lens edge"];
Answer4.text = [NSString stringWithFormat:@"Horizontal measurement"];
break;
case 13:
Question.text = [NSString stringWithFormat:@"In the Boxing System for lenses and frames the DBC represents:"];
Right2.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Distance between lenses"];
Answer2.text = [NSString stringWithFormat:@"Distance between centers"];
Answer3.text = [NSString stringWithFormat:@"Vertical measurement from outer to inner lens edge"];
Answer4.text = [NSString stringWithFormat:@"Horizontal measurement"];
break;
case 14:
Question.text = [NSString stringWithFormat:@"In the Boxing System for lenses and frames the DBC can also represent:"];
Right3.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Distance between lenses"];
Answer2.text = [NSString stringWithFormat:@"Minimum blank size"];
Answer3.text = [NSString stringWithFormat:@"Frame PD"];
Answer4.text = [NSString stringWithFormat:@"Horizontal measurement from outer to inner lens edge"];
break;
case 15:
Question.text = [NSString stringWithFormat:@"In the Boxing System for lenses and frames if there is no prism the MRP is the same as:"];
Right4.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Distance between lenses"];
Answer2.text = [NSString stringWithFormat:@"Minimum blank size"];
Answer3.text = [NSString stringWithFormat:@"Geometric center"];
Answer4.text = [NSString stringWithFormat:@"Optical center"];
break;
case 16:
Question.text = [NSString stringWithFormat:@"On a finished lens, this vertical measurement is from the top of the segment to the lowest part of the lens edge?"];
Right1.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Segment Height"];
Answer2.text = [NSString stringWithFormat:@"Segment Inset"];
Answer3.text = [NSString stringWithFormat:@"Decentration"];
Answer4.text = [NSString stringWithFormat:@"Vertex Compensation"];
break;
case 17:
Question.text = [NSString stringWithFormat:@"This measurement is the difference between the Distance PD and the Near Pd?"];
Right2.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Segment Height"];
Answer2.text = [NSString stringWithFormat:@"Segment Inset"];
Answer3.text = [NSString stringWithFormat:@"Decentration"];
Answer4.text = [NSString stringWithFormat:@"Vertex Compensation"];
break;
case 18:
Question.text = [NSString stringWithFormat:@"The horizontal distance between the MRP (Major Reference Point) and the GC(Geometric Center)?"];
Right3.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Segment Height"];
Answer2.text = [NSString stringWithFormat:@"Segment Inset"];
Answer3.text = [NSString stringWithFormat:@"Decentration"];
Answer4.text = [NSString stringWithFormat:@"Vertex Compensation"];
break;
case 19:
Question.text = [NSString stringWithFormat:@"The correction for the difference between where the eyeglasses are actually worn and the distance the patient is refracted?"];
Right4.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Segment Height"];
Answer2.text = [NSString stringWithFormat:@"Segment Inset"];
Answer3.text = [NSString stringWithFormat:@"Decentration"];
Answer4.text = [NSString stringWithFormat:@"Vertex Compensation"];
break;
case 20:
Question.text = [NSString stringWithFormat:@"This is the distance from the cornea to the back surface of the eyeglass lens:"];
Right1.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Vertex Distance"];
Answer2.text = [NSString stringWithFormat:@"Base Curve"];
Answer3.text = [NSString stringWithFormat:@"NPD"];
Answer4.text = [NSString stringWithFormat:@"Vertex Compensation"];
break;
case 21:
Question.text = [NSString stringWithFormat:@"According to the textbook, what is the proper bifocal placement?"];
Right2.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Segment top at pupil center"];
Answer2.text = [NSString stringWithFormat:@"Segment top at lower eyelid"];
Answer3.text = [NSString stringWithFormat:@"Segment top at lowest part of the pupil"];
Answer4.text = [NSString stringWithFormat:@"Segment top above pupil center"];
break;
case 22:
Question.text = [NSString stringWithFormat:@"According to the textbook, what is the proper trifocal placement?"];
Right3.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Segment top at pupil center"];
Answer2.text = [NSString stringWithFormat:@"Segment top at lower eyelid"];
Answer3.text = [NSString stringWithFormat:@"Segment top at lowest part of the pupil"];
Answer4.text = [NSString stringWithFormat:@"Segment top above pupil center"];
break;
case 23:
Question.text = [NSString stringWithFormat:@"What must be done first to properly measure bifocal height?"];
Right4.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Determine vertex distance"];
Answer2.text = [NSString stringWithFormat:@"Take patients PD"];
Answer3.text = [NSString stringWithFormat:@"Clean the frame"];
Answer4.text = [NSString stringWithFormat:@"Adjust the frame"];
break;
case 24:
Question.text = [NSString stringWithFormat:@"This part of the lensometer holds the lens against the lens stop:"];
Right1.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Lens Clamp"];
Answer2.text = [NSString stringWithFormat:@"Lens Table"];
Answer3.text = [NSString stringWithFormat:@"Power Drum"];
Answer4.text = [NSString stringWithFormat:@"Axis Drum"];
break;
case 25:
Question.text = [NSString stringWithFormat:@"This part of the lensometer provides a flat horizontal surface for the eyeglasses to rest:"];
Right2.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Lens Clamp"];
Answer2.text = [NSString stringWithFormat:@"Lens Table"];
Answer3.text = [NSString stringWithFormat:@"Power Drum"];
Answer4.text = [NSString stringWithFormat:@"Axis Drum"];
break;
case 26:
Question.text = [NSString stringWithFormat:@"This part of the lensometer consists of a wheel that turns and is calibrated in diopters:"];
Right3.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Lens Clamp"];
Answer2.text = [NSString stringWithFormat:@"Lens Table"];
Answer3.text = [NSString stringWithFormat:@"Power Drum"];
Answer4.text = [NSString stringWithFormat:@"Axis Drum"];
break;
case 27:
Question.text = [NSString stringWithFormat:@"This part of the lensometer consists of a wheel that turns and is calibrated in degrees:"];
Right4.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Lens Clamp"];
Answer2.text = [NSString stringWithFormat:@"Lens Table"];
Answer3.text = [NSString stringWithFormat:@"Power Drum"];
Answer4.text = [NSString stringWithFormat:@"Axis Drum"];
break;
case 28:
Question.text = [NSString stringWithFormat:@"This tool is used to measure lens thickness:"];
Right1.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Lens Calipers"];
Answer2.text = [NSString stringWithFormat:@"End Piece Angling Plier"];
Answer3.text = [NSString stringWithFormat:@"Distometer"];
Answer4.text = [NSString stringWithFormat:@"Geneva Lens Clock"];
break;
case 29:
Question.text = [NSString stringWithFormat:@"This tool can be used to adjust pantoscopic tilt:"];
Right2.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Lens Calipers"];
Answer2.text = [NSString stringWithFormat:@"End Piece Angling Plier"];
Answer3.text = [NSString stringWithFormat:@"Lens Axis Turning Plier"];
Answer4.text = [NSString stringWithFormat:@"Geneva Lens Clock"];
break;
case 30:
Question.text = [NSString stringWithFormat:@"This tool can be used to adjust temple spread:"];
Right3.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Lens Calipers"];
Answer2.text = [NSString stringWithFormat:@"End Piece Angling Plier"];
Answer3.text = [NSString stringWithFormat:@"Padded Holding Plier"];
Answer4.text = [NSString stringWithFormat:@"Lens Axis Turning Plier"];
break;
case 31:
Question.text = [NSString stringWithFormat:@"This tool can be used to cut the end of screws:"];
Right4.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Round Plier"];
Answer2.text = [NSString stringWithFormat:@"End Piece Angling Plier"];
Answer3.text = [NSString stringWithFormat:@"Padded Holding Plier"];
Answer4.text = [NSString stringWithFormat:@"Chappel plier"];
break;
case 32:
Question.text = [NSString stringWithFormat:@"This is a chart of horizontal and vertical intersecting lines used to analyze changes in the macula."];
Right1.hidden = NO;
Wrong2.hidden = NO;
Wrong3.hidden = NO;
Wrong4.hidden = NO;
Answer1.text = [NSString stringWithFormat:@"Amslers Grid"];
Answer2.text = [NSString stringWithFormat:@"Duochrome Test"];
Answer3.text = [NSString stringWithFormat:@"Cover/Uncover Test"];
Answer4.text = [NSString stringWithFormat:@"Schirmers Test"];
break;
default:
break;
}
刚刚发布了错误的完整案例。带有“预期表达式”错误消息的行是-(IBAction)OphthalmicInstruments:(id)sender{
答案 0 :(得分:0)
switch(){
case 1: {
}
case 2: {
}
}
尝试将你的案件放在{..},这对我上次有用。
答案 1 :(得分:0)
这只是语法错误,检查分号和&花括号。