2017-06-06 82 views
-1

这看起来不对,我是对吗?这是我使用的代码:我写这段代码错了吗?

_editButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" 
               style:UIBarButtonItemStylePlain 
               target:self 
               action:@selector(editButtonPressed:)]; 

// If we have no threads we don't have the edit button 
self.navigationItem.leftBarButtonItem = _editButton ; nil; 

主要是我所关心的self.navigationItem.leftBarButtonItem = _editButton ; nil;_editButton ; nil;看来我错了。

该代码应该是这样吗? self.navigationItem.leftBarButtonItem = _editButton;

回答

0

这不是本身错误,但它是没有必要的。在_editButton之后的;结束了使nil;成为其自己的声明的陈述,并且正如你可能想象的那样,它什么也不做。两者在功能上是完全相同的,所以你不妨拿出额外的代码。

-1

我以前从来没有使用过这种特殊类型,但是如果它按照预期工作(如果它在调试器上显示为正确,但是这是给定的),那么您的主要指标是可以接受的。