Iphone 无法确定的UI共享应用程序错误
我似乎不明白为什么我总是收到一个错误“在YANAVAppdelegate之前期望表达式”Iphone 无法确定的UI共享应用程序错误,iphone,objective-c,switch-statement,uiapplicationdelegate,Iphone,Objective C,Switch Statement,Uiapplicationdelegate,我似乎不明白为什么我总是收到一个错误“在YANAVAppdelegate之前期望表达式” 我似乎无法弄清楚为什么这不能编译。如有任何意见,我们将不胜感激。。谢谢。 < P>不要在交换机语句中定义变量(CurrurObjor)。< /p> < P>不要在Switter语句中定义变量(CurrurObjor)。< /P> < P>如果需要在case语句中定义变量,可以使用卷筒括号来做它(这项技术也用C++来做): C++ Curu曾经解释过,这给变量提供了一个上下文栈,这些开关栈/ case语句不
我似乎无法弄清楚为什么这不能编译。如有任何意见,我们将不胜感激。。谢谢。 < P>不要在交换机语句中定义变量(CurrurObjor)。< /p> < P>不要在Switter语句中定义变量(CurrurObjor)。< /P> < P>如果需要在case语句中定义变量,可以使用卷筒括号来做它(这项技术也用C++来做):
C++ Curu曾经解释过,这给变量提供了一个上下文栈,这些开关栈/ case语句不自动提供。如果在该上下文中创建了对象,请记住删除/释放对象,否则很容易导致内存泄漏
如果你问我的话,我个人总是在我的案例陈述中使用花括号;)如果你需要在case语句中定义变量,你可以使用卷筒括号(这个方法也用C++来工作):
C++ Curu曾经解释过,这给变量提供了一个上下文栈,这些开关栈/ case语句不自动提供。如果在该上下文中创建了对象,请记住删除/释放对象,否则很容易导致内存泄漏
如果你问我的话,我个人总是在我的案例陈述中使用花括号;)你永远不知道将来你是否需要它们,这会让事情更容易理解-(void) setupMyLocation {
NSArray *viewControllerArray = [navigationUpdateFromDetail.navigationController viewControllers];
NSUInteger parentViewControllerIndex = [viewControllerArray count] - 2;
NSLog(@"Parent view controller: %@", [viewControllerArray objectAtIndex:parentViewControllerIndex]);
switch(parentViewControllerIndex){
case 0:
self.myLocation = navigationUpdateFromDetail.currentLocation;
break;
case 1:
YANAVAppDelegate *currentObject = (YANAVAppDelegate*)[[UIApplication sharedApplication]delegate];
// self.myLocation = currentObject.givenLocation;
break;
default: break;
}
}
-(void) setupMyLocation {
NSArray *viewControllerArray = [navigationUpdateFromDetail.navigationController viewControllers];
NSUInteger parentViewControllerIndex = [viewControllerArray count] - 2;
NSLog(@"Parent view controller: %@", [viewControllerArray objectAtIndex:parentViewControllerIndex]);
switch(parentViewControllerIndex) {
case 0:
self.myLocation = navigationUpdateFromDetail.currentLocation;
break;
case 1:
{
YANAVAppDelegate *currentObject = (YANAVAppDelegate*)[[UIApplication sharedApplication]delegate];
// self.myLocation = currentObject.givenLocation;
break;
}
default:
break;
}
}