[英]Objective-C - Table View Controller - Expected expression
I'm beginer in Objective-C and iOS word, I try to learn how to do nice apps for iOS. 我是Objective-C和iOS单词的初学者,我尝试学习如何为iOS做出色的应用程序。
I try to create a TableViewController, so I make a class, but I have some problem with this code, and I don't know why. 我尝试创建一个TableViewController,所以我创建了一个类,但是这段代码有一些问题,我不知道为什么。 I describe all in the code in the comments.
我在注释的代码中描述了所有内容。
This is Code. 这是代码。
BooksTableViewController.m
import "BooksTableViewController.h"
@implementation BooksTableViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil //Semantic Issue - Designated initializer missing a 'super' call to a designated initializer of the super class
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];// Parse Issue - Expected expression
if(self){
self.title = @"Books";
self.tabBarItem.image = [UIImage imageNamed:@"books8.png"];
self.imiona = @[@"Pan Tadeusz", @"Potop", @"Lalka", @"Uczta dla wron", @"Symfonnia C++"];
}
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.imiona.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Title"];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Title"];
}
cell.textLabel.text = self.imiona[indexPath.row];
return cell;
}
@end
Thank You for help ! 谢谢你的帮助 !
In initWithNibName
at nimNameOrNil
there is the problem. 在
nimNameOrNil
initWithNibName
中存在问题。 All you have to do is: Change this line 您要做的就是:更改此行
self = [super initWithNibName:<#nibNameOrNil#> bundle:nibBundleOrNil];
to 至
self = [super initWithNibName: nibNameOrNil bundle:nibBundleOrNil];
Notice: the <#nibNameOrNil#>
with nibNameOrNil
注意:
<#nibNameOrNil#>
与nibNameOrNil
<#nibNameOrNil#> is from the code sense auto fill. <#nibNameOrNil#>来自代码意义自动填充。 You'll note that the text in Xcode is gray.
您会注意到Xcode中的文本是灰色的。 You need to type nibNameOrNil over it.
您需要在其上键入nibNameOrNil。 Seems like an Xcode bug.
好像是Xcode的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.