获得此警告:不兼容的指针类型使用类型为“*”的表达式初始化“*”

时间:2012-08-15 09:49:48

标签: objective-c xcode

我收到了这个警告,但不知道我做错了什么,这是一个用转换来改变视图的简单代码。我没有使用Xcode 3.x这个错误,但现在有了4.x问题开始了。虽然这只是一个警告而且代码编译完美,但我想知道问题是什么。

-(IBAction)swapViews:(id)sender{
DemoViewController *view3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
view3.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:view3 animated:YES];}

感谢您的所有帮助

2 个答案:

答案 0 :(得分:1)

 //DemoViewController*   ThirdViewController*   ????
 //the warning is in this line 
DemoViewController *view3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
view3.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:view3 animated:YES];

我认为你想做的是。

ThirdViewController *view3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];

答案 1 :(得分:0)

你忘了花括号吗?

-(IBAction)swapViews:(id)sender {
    DemoViewController *view3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
    view3.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:view3 animated:YES];
}